FSEEK( ) Function Example

The following user-defined function uses FSEEK( ) to return the size of a file. If you don't pass parameters to the user-defined function, it returns –2. If the file cannot be found, the user-defined function returns –1.

FUNCTION fsize2
PARAMETERS gcFileName  && File to be checked
PRIVATE pnHandle,pnSize
IF PARAMETERS( ) = 0
   RETURN -2  && Return -2 if no parameter passed
ELSE
   IF !FILE(gcFileName)
      RETURN -1  && Return -1 if file does not exist
   ENDIF
ENDIF
pnHandle = FOPEN(gcFileName)   && Open file
pnSize = FSEEK(pnHandle,0,2)   && Determine file size, assign to pnSize
=FCLOSE(pnHandle)  && Close file
RETURN pnSize  && Return value