XbZ_FileRead()
Previous  Top  Next

XbZ_FileRead() - Read contents of File from Disk.

Syntax

XbZ_FileRead(<cFileName>,  
            [<@nError>]) --> cData  

Parameters

<cFileName>  
<cFileName> contains the (relative or fully qualified) File Name (with or without Path) of the File that should be read. If no Path or a relative Path is given, the file is searched for in the Current Directory of the Current Drive or in the given relative path from the Current Directory of the Current Drive.  

<@nError>  
After XbZ_FileRead() returns, the optional Parameter <@nError> will contain either Zero "0" if the function was successful, or an OS Error Code greater than "0", if an error occurred. This parameter is optional, but must be passed by reference if it should be updated.  

Returns

This function returns the contents of <cFileName> as a string.  

Description

This function reads and returns the contents of <cFileName> as a string, and updates <nError> with any OS Error Codes generated by the FOpen() or FRead() functions.  

Example

LOCAL nError := XbZ_OK  
LOCAL cFile  := 'XbZLib.chm'  
LOCAL cData  := XbZ_FileRead(cFile, @nError)  
if nError == XbZ_OK  
   QOut(cFile + ' contains: ' + alltrim(str(len(cData))) + ' Bytes')  
else  
   QOut(cFile + ' could not be read!')  
   QOut('Error: ' + alltrim(str(nError)) + ' - ' + ;  
        DosErrorMessage(nError))  
endif