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 - feof() test if a text file is at eof http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 feof()              Test if a text file is at EOF
------------------------------------------------------------------------------
 Declaration
   fileio.hdr

 Syntax
   func logical feof extern
   param file fStream

 Arguments
   fStream is the file stream to manipulate.

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

 Description
   The feof() function returns .t. if the DOS read/write pointer is at the
   end of file for fStream.

   The feof() function will always return .t. if the file is opened in a mode
   other than F_READ.

 Example
   #define EXAMPLE_FILE
   #include example.hdr

   func logical ShowFile
   param const char cFile
   // Display a file in a window
   vardef
      file    fTemp
      char    cLine
      _SLIST  pList
      logical lSuccess
   enddef
   lSuccess := .f.
   if fopen( fTemp, cFile, F_READ, F_TEXT )             // open file
      lSuccess := .t.
      pList := pickinit()                               // create list
      do while .not. feof( fTemp )                      // to end of file
         fgetln( fTemp, cLine )                         // read a line
         pickadd( pList, cLine )                        // add to list
      enddo
      fclose( fTemp )                                   // close file
      clear
      @ 0, 0 to __max_row, __max_col double             // frame
      pickdisp( pList, 1, 1, __max_row - 1, __max_col - 1 ) // display list
      pickclear( pList )                                // clear list
   endif
   return( lSuccess )
   endfunc
   
   proc Test_feof
   vardef
      logical lShown
   enddef
   setcolors( CYAN_BLACK, BLUE_WHITE, 0 )
   lShown := ShowFile( argv( 1 ) )
   __syscolor[ CLR_STD ] := __doscolor
   if lShown
      clear
   else
      ? "File not found"
   endif
   endproc

   proc main
   Test_feof()
   endproc

See Also: fclose() fopen()

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