Read text file line by line in a loop.
read-line starts the loop in which a text <file> is read line by line into <line content> (which can be created with "define" clause if it doesn't exist), with end-read-line ending this loop. Once the end of file has been reached, or an error occurs, the loop exits. The length of a text line can be obtained with optional <length/status>, which will be VV_ERR_READ if there is an error in reading file, or VV_ERR_OPEN if file cannot be opened, or VV_OKAY if end-of-file has been reached. Check <length/status> variable within the loop to obtain the length of the currently read-in line, or after the loop for successful completion or an error condition.
Buffer allocated for each line read may or may not be reused with each iteration. For that reason, if you want to save read-in lines for use beyond the code between read-line and end-read-line, save a copy of it using copy-string
<delimiter> separates the lines in the file, and is by default new line, however it can be any character (note that it is not a string, but a single character).
Each line is null-terminated and new line (or a <delimiter>) remains if it was present (last line may not have it). There is no limit on line length, and Vely will automatically adjust the size of <line content> to accommodate the line length.
<file> can be a full path name, or a path relative to the application home directory (see vv
Use standard C break and continue statements to exit and continue the loop.
To read a text file line by line, and display as a web page with line breaks:
read-line "/home/user/dir/file" to define one_line status define len
@Line length is <<p-num len>>, line is <<p-web one_line>><br/>
To read a text file delimited by "|" character:
read-line "/home/user/dir/file" to define one_line status define len delimiter '|'