FRead Function

Action

Reads data from a file, starting at the position indicated by the file pointer.

Include file

Kernel.bdh

Syntax

FRead(in hFile : number,
      out sData : string,
      in nDataSize : number,
      out nRead : number optional): boolean;

Return value

  • true if the number of bytes that were actually read is equal to the number of bytes that you specified should be read.

  • false otherwise

Parameter Description
hFile Valid handle to an open file. This handle must have been returned from a previous call to FOpen.
sData Buffer that receives the data
nDataSize Number of bytes to read
nRead Variable receiving the number of bytes actually read (optional)

Example

dcltrans
  transaction TMain
  var
    hFile, nRead : number;
    sData : string;
  begin
    // open text file for reading
    FOpen(hFile, "c:\\temp\\dummyfile.txt");
    write("file opened"); writeln;
    // read the first 5 bytes and display them
    FRead(hFile, sData, 5, nRead);
    write(nRead); write(" bytes read"); writeln;
    write(sData); writeln;
    // close file
    FClose(hFile);
  end TMain;

Output

file opened
5 bytes read
Hello

Sample scripts

WebFileUpload01.bdf