DADiSP Worksheet Functions > Function Categories > File Manipulation > STRFILE
Reads and converts a plain text file into a string with embedded newlines.
STRFILE("filename", reverse, noprocess)
"filename" |
- |
Optional. A Window, defaults to the current Window. |
||||
reverse |
- |
Optional. An integer, the reverse read file flag:
|
||||
noprocess |
- |
Optional. An integer, disable brace expansion and comments:
|
A string.
Consider the file "max.txt" with the following contents:
The maximum is {max} and the minimum is {min}.
W1: 1..100;label(strfile("max.txt"))
labels W1 with the text "The maximum is 100.000000 and the minimum is 1.000000." The {max} and {min} fields in the file are automatically evaluated.
strfile("symbols.txt", 1, 1)
returns the contents of the file symbols.txt as a single string with embedded newlines, and the lines of the file in reverse order. Expressions in braces are not interpreted.
STRFILE is useful with annotation functions such as TEXT for placing the contents of text files in Windows. For example:
{0, 1, 2};text(1, 1, strfile("ascii.txt"))
Set noprocess to 1 to load the file "as is" without expansion of expressions in {} and without interpreting ! as a single line comment.