LogiView

Command 'readln'

     

This command is used to read a file line-by-line.

The contents of a line is assigned to a variable of the forwarded variable list. It must be ensured that the variable types correspond to the contents of the appropriate line.

This command must not be called with a conditional instruction.
 

Syntax:

  readln({INT_VAR},{VAR_LIST})
 

I/O parameters:

{INT_VAR} Integer variable with file ID number (is assigned when opening the file).
{VAR_LIST} List of variables that are assigned values. The following values are valid for logic variables:
TRUE FALSE
'TRUE' 'FALSE'
'Y' 'N'
'J' 'n'
'O'  
'y'  
'j'  
'o'  
   
 

Return value:

 
-  
 

Return code:

 
0 No errors during command execution.
 

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   DOCU_LOGIC_1 = eof (DOCU_INT_1)	
110   while ( DOCU_LOGIC_1 != TRUE)	
120     readln(DOCU_INT_1,DOCU_STRING_1)	
130     readln(DOCU_INT_1,DOCU_INT_2)	
140     put(DOCU_STRING_1)	
150     put(DOCU_INT_2)	
160     DOCU_LOGIC_1 = eof (DOCU_INT_1)	
170   done	
180   close(DOCU_INT_1)	
190 C Deleting file "test.file"	
200   delete("\tmp\test.file")	
  Result:
 

test.file:

Zeile 1
5
Zeile 2
  In the last line the value "5" is returned again because the end of file is reached before all variables in the list are assigned a value. In this case the variable maintains its value.

Functions and commands: File Interface