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 - frewind() reset file pointer to beginning of a file stream http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 frewind()           Reset file pointer to beginning of a file stream
------------------------------------------------------------------------------
 Declaration
   fileio.hdr

 Syntax
   func logical frewind extern
   param file fStream

 Arguments
   fStream is the file stream to manipulate.

 Return
   A logical indicating the success of operation.

 Description
   frewind() positions the file read pointer to the beginning of an open
   buffered input file stream, and fills the read buffer anew. The file
   stream must be opened in read-only mode, otherwise this function has
   no effect.

 Example
   #define EXAMPLE_FILE
   #include example.hdr

   // Read the first line of text from a file until Esc gets pressed
   
   proc Test_frewind
   vardef
      file fTemp
      uint nKey
      char cLine
   enddef
   if fopen( fTemp, "c:\autoexec.bat", F_READ, F_TEXT ) // open file
      nKey := 0
      do while nKey != K_ESC
         frewind( fTemp )                 // back to beginning of file
         fgetln( fTemp, cLine )           // read a line
         ? cLine                          // display line
         nKey := getkey()                 // wait for keypress
      enddo
      fclose( fTemp )                     // close file
   endif
   endproc

   proc main
   Test_frewind()
   endproc

See Also: fclose() fopen()

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