STRING - string I/O support.

Usage:

unit = open( [unit, ] string, "rs" [, pos ] );
unit = open( [unit, ] string, "ws" [, pos [, eos] ] );
unit = open( [unit, ] string, "as" [, pos [, eos] ] );

Description:

B makes core-to-core I/O easy by allowing you to OPEN a string for reading and writing in the same way that you would open a file. An open string is associated with a specified unit so that calls to GETCHAR and PUTCHAR on that unit read from or write into the string.

The optional "pos" is a character offset into the string. The character at the beginning of the string has an offset of zero, the next character has an offset of one, and so on. If "pos" is specified, reading and writing will take place starting at the character offset rather than the beginning of the string.

Normally, a '*e' (octal 000) is placed at the end of the string when the unit is closed; if "eos" is specified with a non-zero value, no '*e' will be written.

OPEN always returns the unit number; if you want to specify the unit to be opened, you can give it as an argument before "string" as shown in "expl b lib open".

unit = open( string, "as" );

is equivalent to

unit = open( string, "ws", length(string) );

Any of the stream-oriented I/O routines may be used on a unit which is a string. This includes GETNUM, PUTNUM, READF, PRINTF, GETSTR, and PUTSTR, among others. However, you may not use any of the seek operations (like .SEEK and .TELL) on strings.

Copyright © 1996, Thinkage Ltd.