Reads a line from file.
filereadln <file handle> <strvar>
Reads a line from the file specified by <file handle>.
The line is written into the string variable <strvar>.
The file pointer is moved to the beginning of the next line.
If the file pointer reaches the end of the file while reading the line, the system variable "result" is set to 1. Otherwise, "result" is set to zero.
When a line only includes a new line, the string variable is empty and "result" is set to zero.
; Open a file. fileopen fhandle 'test.txt' 0 :loop ; Read a line from the file. filereadln fhandle line if result goto fclose ; Display the line. messagebox line 'test.txt' ; Repeat until the end of the file. goto loop :fclose ; Close the file. fileclose fhandle
; Open a file. fileopen fhandle 'test.txt' 0 while 1 ; Read a line from the file. filereadln fhandle line if result=1 then break endif ; Display the line. messagebox line 'test.txt' ; Repeat until the end of the file. endwhile ; Close the file. fileclose fhandle
; Search a keyword and replace in the file. infile = 'testdata.txt' outfile = 'testdata_output.txt' oldkeyword = 'BBB' newkeyword = 'zzz' fileopen ifd infile 0 fileopen ofd outfile 0 while 1 filereadln ifd line if result=1 then break endif strreplace line 1 oldkeyword newkeyword filewriteln ofd line endwhile fileclose ifd fileclose ofd ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; [testdata.txt] AABBBCCCCDDDDD ###DDCCCBBBBAAAAA#### 1234567890 [testdata_output.txt] AAzzzCCCCDDDDD ###DDCCCzzzBAAAAA#### 1234567890