Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - fbeof() check if a binary file is at eof http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 fbeof()             Check if a binary file is at EOF
------------------------------------------------------------------------------
 Declaration
   fileio.hdr

 Syntax
   func logical fbeof extern
   param value _HFILE hFile

 Arguments
   hFile is the handle of the file to manipulate.

 Return
   A logical indicating if the file pointer is at the end of file.

 Description
   The fbeof() function returns .t. if the file associated with hFile is
   positioned at its end. fbeof() always returns .t. if the file has been
   opened in append mode. Do not use fbeof() on one of the DOS predefined
   file handles.

 Example
   #define EXAMPLE_FILE
   #include example.hdr

   proc Test_fbeof
   vardef
      _HFILE hFile                                // file handle
      byte   aLine[ 255 ]                         // line buffer
      char   cLine based aLine                    // displayable line
      int    n
   enddef
   n := 0
   if fbopen( hFile, "c:\autoexec.bat", FB_READ ) // open file for reading
      ? "Contents of autoexec.bat"
      ?
      do while .not. fbeof( hFile )               // display the file
         fbread( hFile, aLine[n], 1 )             // read a byte from the file
         n++
         if aLine[n-1] == 13                      // if CR char found
            aLine[n-1] := 0                       // close string
            ? cLine                               // display line
            fbread( hFile, aLine[ 0 ], 1 )        // skip the LF
            n := 0
         endif
      enddo
      fbclose( hFile )                            // close file
   endif
   endproc

   proc main
   Test_fbeof()
   endproc

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson