open_string

open_string — allows a string to be used as a file.

Syntax

open_string (string)

		

Arguments

string

A string.

Returns

A pseudo-file that contains the string if successful, otherwise nil.

Description

This function allows a string to be used as a pseudo-file to facilitate reading and writing to a local buffer. All read and write functions which operate on a file can operate on the result of this call. An attempt to write to the string always appends information destructively to the string. Subsequent reads on the string can retrieve this information. A string is always opened for both read and write.

Example

Gamma> s = open_string("Hello there.");
#<File:"String">
Gamma> read_line(s);
"Hello there."
Gamma> s = open_string("Hello there.");
#<File:"String">
Gamma> read(s);
Hello
Gamma> read(s);
there.
Gamma> read(s);
"Unexpected end of file"
Gamma> 
		

See Also

close, open, read, read_char, read_double, read_float, read_line, read_long, read_short, read_until, terpri, write, writec