LogiView

Command 'rewind'

     

This command is used to reset the file pointer to the beginning of the specified file. You can use this command to determine the number of lines of a file (using 'eof') before starting the processing.

This command must not be called with a conditional instruction.
 

Syntax:

  rewind({INT_VAR})
 

I/O parameters:

{INT_VAR} Integer variable with file ID number (is assigned when opening the file).
-  
 

Return value:

 
-  
 

Example:

  Declaration of Variables
 
 10 C Generating file "test.file"	
 20 DOCU_LOGIC_1=FALSE	
 30   DOCU_INT_1 = open("\tmp\test.file","w")	
 40 writeln(DOCU_INT_1,"Line 1")	
 50 writeln(DOCU_INT_1,5)	
 60   Writeln(DOCU_INT_1,"Line 2")	
 70 close(DOCU_INT_1)	
 80 C Reading data from file "test.file"	
 90   DOCU_INT_1 = open("\tmp\test.file","r")	
100   readln(DOCU_INT_1,DOCU_STRING_1)	
110   readln(DOCU_INT_1,DOCU_INT_2)	
120 put(DOCU_STRING_1)	
130   put(DOCU_INT_2)	
140 C Jump to the start of file	
150   rewind(DOCU_INT_1)	
160 C Reading data from file "test.file"	
170   readln(DOCU_INT_1,DOCU_STRING_1)	
180 put(DOCU_STRING_1)	
190 close(DOCU_INT_1)	
200 C Deleting file "test.file"	
210   delete("\tmp\test.file")	
  Result:
 

test.file:

Line 1
5
Line 2

 

Functions and commands: File Interface