b = file_handler.read(string_variable ‖ string_list);
The
File.read function reads one or more lines of text from the
File associated with
file_handler. After the read the file pointer is positioned to the next line in the file. This function reads lines sequentially. This function is equivalent to the
fileread function.
If a
string_variable is provided as a argument, a single line of text is read and placed in the variable, which is either a temporary
string variable or an alphanumeric dictionary item. If the dictionary item is longer than the line of text, blanks will be added at the end. If the item is shorter, the line of text will be truncated.
Alternatively, a string
List can be used as an argument. In this case, all remaining lines in the file are read and stored in
string_list.
The function returns a logical value of 1 (true) if successful and 0 (false) otherwise.
File occupation_codes_file;
occupation_codes_file.open("Occupation Codes.txt");
// approach 1
string code;
while occupation_codes_file.read(code) do
// do something with the single code
enddo;
// approach 2
List string all_codes;
occupation_codes_file.read(all_codes);
// do something with all of the codes
occupation_codes_file.close();