STREAM - FRED stream directives.

Input to FRED can be thought of as a stream of characters that the editor first reads and then interprets. Stream directives are special characters that direct this input stream without having any effect on the editing process itself. Stream directives are also called escapes.

For example, you may have a number of commands stored in a buffer called (work). With the right stream directive, you can tell FRED to take its commands from (work) rather than the terminal. In this way, the input stream (what FRED is seeing) is diverted from the terminal to (work).

A stream directive character is typed as a letter (either upper or lower case) preceded by a special character called the escape character. The default escape character is the backslash "\", and this is the escape character used in all documentation for FRED. It is possible to change the escape character in FRED by using the O+IE command. If you wish to refer to the escape character itself and not its special meaning, you must type a pair of the characters (e.g. "\\").

The various stream directive characters in FRED are listed below.

\B(bufname)
inserts the contents of the buffer (bufname) into the input stream. For example,
a
\b(a)\f

appends the contents of buffer (a) to the current buffer. The \F at the end of the line puts FRED back into command mode.

Once FRED has reached the end of the text in a \B buffer, FRED returns to its original source of input. The J commands can be used to return control to the original source before the end of the buffer.

\B constructions may be used recursively to any level. In other words, a buffer that has been put into the input stream with a \B may contain further \B constructions.

If an error occurs while input is being taken from a buffer, FRED will attempt to print the remaining contents of any buffers currently in the input stream, but will not execute any of those contents. This is useful in debugging buffer programs. If there are more than three lines remaining to be executed, FRED will simply print the first three lines and will print "..." in place of the rest. After this information is printed, FRED will take its next input from the terminal.

The \B construction works in both command and text input mode. If there are a set of commands you intend to perform several times, you can save some typing by putting those commands in a buffer (say (work)) and executing those commands with \B(work) whenever desired. The same principle holds if you have some lines of text that occur several times in a report (e.g. Copyright 1981, by R.VanWinkle). The repeated text can be stored in a buffer (say (lines)) and put into place by typing \B(lines) while in text input mode.

\C
tells FRED to take the next character literally, regardless of any special meaning it might normally have. The character following the \C is said to be escaped. For example, a \B normally has the special meaning discussed above. However, \C\B tells FRED that you wish to use a literal \B character without its special meaning. This is frequently typed when writing buffer programs.
\E(patname)
is special only inside patterns. When (patname) has been associated with a pattern using the E command, \E(patname) represents the associated pattern.
\F
marks the end of text input.
\L(bufname)
is similar to \B in that it places the contents of buffer (bufname) into the input stream. The difference is that every character in (bufname) is treated as if it is preceded with a \C. This means that stream directives such as \B appearing in (bufname) are not expanded (since \C\B tells FRED to take \B literally, without its special stream directive meaning). Bear in mind that a \C in front of a letter tells FRED to pay attention to whether the letter is in upper or lower case. Thus if (buf) contains NAME, the command
b(\L(buf))

defines a buffer called (NAME). Since the \C characters tell FRED to pay attention to case, (NAME) is not the same buffer as (name), (Name), and so on.

\N(regname)
is replaced by the digits corresponding to the contents of the number register (regname), printed in the format specified for the register by any format commands.
\O
tells FRED to use any special meaning associated with the next character, regardless of current option settings. In other words, \O turns on a character's special meaning just as \C turns the special meaning off.
\R
diverts the input stream to the terminal for one line of input. No stream directives typed in on this line are effective. The new-line character ending the line is discarded. Each character typed from the terminal is treated as if it has a preceding \C. Here is an example of how this might be used.
jp/Answer question, yes or no?/
a \R\F
t/n/

This uses JP to prompt for a yes or no answer. The answer is appended to a buffer, then the T command is used to determine if the answer contained an "n".

\S(bufname)
is similar to \L except that all new-line characters in (bufname) are removed as the buffer is put into the input stream. As with \L, the \C characters in front of the letters in (bufname) tell FRED to pay attention to whether letters are in upper or lower case.
\W
is replaced by the file name associated with the current buffer. For example,
!jrn \w

submits the current file as a batch job via the JRN command.

\8
always precedes another character (that we'll call c). \8 followed by c indicates a single character whose seven low order bits are the same as the ASCII representation of c and whose eighth bit is turned on. For example, the ASCII representation for the letter a is octal 141. Thus \8a is octal 341 (= 141 + 200).
\9
is similar to \8, but indicates that the ninth bit of a character is turned on. For example, \9a is octal 541 (= 141 + 400). The two can be combined as in \9\8a, octal 741.
\ddd
stands for the nine-bit character whose octal representation is the three octal digits ddd. For example, \014 is changed to the character octal 014, the formfeed character. Characters entered in this manner are automatically considered to be preceded by a \C.

Note that all the special stream directive constructions are treated as single characters in FRED. Internally, they are stored as ASCII control characters that are seldom used. This means you cannot create a \C by putting a \ character in front of a C. Similarly, \\B is not the same as \C\B. \\B is two characters, a backslash followed by a B. \C\B is a single character, a \B escaped with \C.

Stream directive characters only have their special meaning when they appear in FRED's input stream. They do not have their special meanings when text is being read with the R command or written with W.

Alternate Character Formats:

Some terminals do not have some of the special characters recognized by FRED. Because of this, FRED will accept alternate input formats for some characters. For example, \( is accepted as an alternate input form of the left brace {. A list of all stream directives and alternate character formats can be found in "expl fred escapes".

Copyright © 1998, Thinkage Ltd.