b = file_handler.write(messageʃ, argument1, ..., argumentNʅ);
The
File.write function writes one or more lines of text to the
File object associated with
file_handler. This function is equivalent to the
filewrite function.
The
message is either a string expression or a numeric
message number that contains the text that is written to the file. If the text contains any
message formatters, the optional arguments
argument1 to
argumentN will be inserted into the text. There are some additional options for file output:
- If you want to break a line of text into two lines, place '\n' (newline) where you want the line divided.
- If you want a text line to begin on a new page, place '\f' (form feed) at the beginning of the text string.
- If using the Original logic version, to output \n or \f as text instead of a new line or a new page, use a double backslash (e.g., "\\n").
Alternatively, the
message can be a string
List. If a List is provided, then each string contained in the List is written to the file, allowing for the output of multiple lines of text with one function call.
The function returns a logical value of 1 (true) if successful and 0 (false) otherwise.
File data_file_report;
data_file_report.open("Data File Report.txt", create);
List string data_file_listing;
dirlist(data_file_listing, "Data", "*.csdb");
data_file_report.write("There are %d files in the data directory:", data_file_listing.length());
data_file_report.write("");
data_file_report.write(data_file_listing);
data_file_report.close();
view(filename(data_file_report));