DADiSP Worksheet Functions > Function Categories > File Manipulation > STRFILE

 

STRFILE

Purpose:

Reads and converts a plain text file into a string with embedded newlines.

Syntax:

STRFILE("filename", reverse, noprocess)

"filename"

-

Optional. A Window, defaults to the current Window.

reverse

-

Optional. An integer, the reverse read file flag:

0:

Read file from the beginning (default)

1:

Read file from the end

noprocess

-

Optional. An integer, disable brace expansion and comments:

0:

Expand expressions in braces {} and consider the ! character a single line comment (default)

1:

Do not process, load file as is.

Returns:

A string.

Example:

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.

Example:

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.

Remarks:

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.

See Also:

STRCAT

STRLIST

TEXT