FCREATE( ) Function Example

IF FILE('errors.txt')  && Does file exist? 
   gnErrFile = FOPEN('errors.txt',12)     && If so, open read-write
ELSE
   gnErrFile = FCREATE('errors.txt')  && If not create it
ENDIF
IF gnErrFile < 0     && Check for error opening file
   WAIT 'Cannot open or create output file' WINDOW NOWAIT
ELSE  && If no error, write to file
   =FWRITE(gnErrFile , 'Error information to be written here')
ENDIF
=FCLOSE(gnErrFile )     && Close file
IF gnErrFile > 0
MODIFY FILE errors.txt NOWAIT  && Open file in edit window
ENDIF