FRED REFERENCE SUMMARY

Below we summarize the commands for FRED and their default line addresses. "(.)" means that a command will operate on the current line if no address is specified. "(.,.)" means that a command will operate on the current line if no addresses are specified, and on the single addressed line if one address is specified.

Commands which do not require a <nl> as part of their format may be placed one after the other on the same line. Such commands may be separated by one or more spaces; sometimes no spaces are necessary.

Placing an item in square brackets (e.g. "[item]") in the formats below means that the item is optional. Separating items with or-bars as in "item1|item2|item3" means that the user has the choice of any of the given items.

Commands:

A)   (.)A<text>                  Append text after line
B)      B<bufname>               Buffer
C) (.,.)C<text>                  Change lines
D) (.,.)D                        Delete lines
E)      E<patname>/<pattern>/    Name pattern
F)      F                        Print Facts
        F <filename>             Set buffer filename
        FB                       Print buffer facts
        FE                       Print pattern facts
        FF                       Print buffer file facts
        FN                       Print number registers
        FO                       Print option facts
        FV                       Print Version
        F?                       Show questionable buffers
G) (1,$)G[~]/<pattern>/<commands><nl>   Global
I)   (.)I<text>                  Insert text before line
J)      JM <remarks><nl>         Jump Message
        JM/<remarks>/
        JP <remarks><nl>         Jump Prompt
        JP/<remarks>/
        JE <remarks><nl>         Jump Exit
        JE/<remarks>/
        JO[T|F]                  Jump Out
        JB[T|F]                  Jump Break
        J<label>[T|F| ]<commands><nl>   Jump to label
        J[T|F]                   Jump line
K) (.,.)K<bufname>               Kopy lines to buffer
L)      L[ <filename>]           List file on terminal
M) (.,.)M<bufname>               Move lines to buffer
N)   (.)N<regname>:<number>      Number (assign)
        N<regname>|                (absolute value)
        N<regname>-                (switch signs)
        N<regname>+<number>        (add)
        N<regname>-<number>        (subtract)
        N<regname>*<number>        (multiply)
        N<regname>/<number>        (divide)
        N<regname>%<number>        (remainder)
        N<regname>~                (bit complement)
        N<regname>&<number>        (bitwise AND)
        N<regname>|<number>        (bit inclusive OR)
        N<regname>^<number>        (bit exclusive OR)
        N<regname>}<number>        (right bit shift)
        N<regname>{<number>        (left bit shift)
        N<regname>=<number>        (test equality)
        N<regname><<number>        (test less than)
        N<regname>><number>        (test greater than)
        N<regname>B<number>        (set base)
        N<regname>D<number>        (set digits)
        N<regname>F<char>          (set fill char)
        N<regname>P                (print)
        N<regname>A                (assign line address)
        N<regname>L                (count characters)
O)      O[+|-]<opt-char>[<parameters>]   Options
  Input options
        O[+|-]I(                   (parentheses on names)
        O[+|-]IL<char>             (lower case input)
        O[+|-]IU<char>             (upper case input)
        O[+|-]IE<char>             (set escape char)
        O[+|-]IF                  (print linefeed on return)
        O[+|-]IA/<string/         (set text input prompt)
        O[+|-]IC/<string>/         (set command prompt)
        O[+|-]IR/<string>/         (string after return)
        O[+|-]I\F                  (is \F necessary?)
  Output Options
        O[+|-]OO                   (print oddities in octal)
        O[+|-]OL                   (lower case output)
        O[+|-]OU                   (upper case output)
        O[+|-]O<chars>             (alt. output format)
  String Options
        O[+|-]SD                   (ignore case in matches)
        O[+|-]S&                   (& and {}x in S command)
        O[+|-]S<chars>             (pattern chars)
        O[+|-]S/                   (is final "/" needed?)
Other Options
        O[+|-]P<number>            (set pagesize)
        O[+|-]Q                    (quit option)
        O[+|-]B<number>            (in-core pages)
        O[+|-]C/<str1>/<str2>/     (translate a string)
        O[+|-]R                    (default read perms)
        O[+|-]T<tab-list>          (set tabs)
        O[+|-]M                    (monitor)
        O[+|-]W                    (set line width)
P) (.,.)P                        Print
   (.,.)<nl>                     Print addressed lines
        <nl>                     Print ".+1"
Q)      Q<nl>                    Quit
        QQ<nl>                   Quit despite quest. buffer
        Q!<TSS command><nl>      Quit with system call
R)   (0)R[X][ <filelist>]<nl>    Read file
     (0)R[X]<start>[ <filelist>]<nl>
     (0)R[X]<start>-<finish>[ <filelist>]<nl>
     (0)R[X]<start>,<count>[ <filelist>]<nl>
S) (.,.)S/<pattern>/<string>/    Substitute
T) (.,.)T[~]/<pattern>/          Test for pattern
U)   (.)U[<number>][T|F|E] <commands><nl>   Repeat Until
V)      V                        Void last active line
W) (1,$)W[X][A|B][ <filename>]<nl>   Write file
Y)      Y                        Why error?
Z)   (.)Z                        Set address
     (.)ZA<bufname>              Append buffer
   (.,.)ZB                       Sort into descending order
        ZC                       Clear questionable flag
        ZD<bufname>              Delete buffer
        ZG<bufname><commands><nl>  Gather output
   (.,.)ZI                       Zap in tabs
   (.,.)ZK<bufname>              Zap Kopy
   (.,.)ZL[/<pattern>/]          Zap Lower case
   (.,.)ZM<bufname>              Zap Move
   (.,.)ZO                       Zap out tabs
        ZP<bufname>              Print buffer
        ZR <filename>            Go to buffer with file
   (.,.)ZS                       Sort into ascending order
   (.,.)ZT/<string1>/<string2>/  Translate
   (.,.)ZU[/<pattern>/]          Zap Upper case
        ZV                       Void most recent V
   (1,$)ZW<write options>        Write append
!)      !<TSS command>           Perform TSS command
")   (.)"<comment><nl>           Comment
#)      #                        Print count register
=)   (.)=                        Print line #
:)      (.):[<number>]            Print window
\)      \[<number>]               Wait

Stream Directives

\B<bufname>
Inserts contents of buffer <bufname> in input stream. May be used recursively.
\C<char>
Causes <char> to be taken literally.
\E<patname>
Represents pattern previously associated with <patname> by an E command. Only special inside a pattern.
\L<bufname>
Similar to \B<bufname> except that all the characters in <bufname> are considered to be preceded by a \C.
\N<regname>
Places the contents of number register <regname> in the input stream, according to any applicable register format commands.
\O<char>
Causes <char> to take on any special meaning it can have in this context, regardless of current option settings.
\R
Takes one line of input from the terminal. No stream directives on this line are effective. The <nl> character at the end of the line is discarded.
\S<bufname>
Similar to \L<bufname> except that all <nl> characters in <bufname> are removed as the buffer is placed into the input stream. Special pattern characters in <bufname> are taken literally, without their special meanings.
\W
Replaced by the file name associated with the current buffer.

File I/O

The W command will create files it cannot find. If the specified file name is less than nine characters and does not contain a "/" or "$", a temp file is created; otherwise a permanent file is created.

Permanent files are removed from the AFT after every successful read or write; temp files are not removed from the AFT.

When a permanent file is read or written without a specified line address, the FULL name of the file is associated with the current buffer. The file name associated with the current buffer is not changed if line addresses are specified. If a file with a password is read or written without specified line addresses, FRED will associate the name of the file with the current buffer, but will strip away the password of the file. Thus the user must specify the password every time the file is read or written, since FRED will not remember the password.

If an I/O error occurs in accessing a file, the Y command can be used to obtain an explanation of why the access failed.

Patterns and the Pattern Matcher

Special Characters:

^
This character matches the null character beginning a line.
$
This character matches the null character before the <nl> in lines which have a <nl>. In lines without a <nl>, "$" matches the physical end of line.
.
This character matches any character except <nl>.
+
The construction "<pattern>+" matches any sequence of one or more strings matching <pattern>.
*
The construction "<pattern>*" matches any sequence of zero or more strings matching <pattern>.
@
The construct "@(<n>)" matches the null string immediately before the <n>th character in a line. "@(-<n>)" matches the null string immediately after the <n>th character from the end of a line. "@(-1)" matches the null string immediately before the <nl>. "@(0)" matches the null string immediately after the <nl>. "@(<n>-)" matches the null string before the <n>th character in a line or before any previous character in the line. "@(<n>+)" matches the null string before the <n>th character in a line or before any subsequent character in the line.
|
The construction <pattern1>|<pattern2> matches any string which matches either <pattern1> or <pattern2>.
()
Any pattern may be placed in parentheses to obtain a pattern which matches the original.
[
"[<string>]" defines a pattern which matches any character in <string>. "[^<string>]" defines a pattern which matches any character NOT in string.
{}
The construction {<pattern>}<char> creates a pattern in which any string matching <pattern> is associated with the name <char>. <char> may be used to represent the matching string on the right hand side of S commands.
\E
See section on Stream Directives.
#
The "#" prevents the Pattern Matcher from backing up and making a second attempt to find a string matching a given pattern.
//
The null pattern // matches the pattern most recently encountered.
NULL
The null string (generally written () to distinguish it from the null pattern //) matches any null character.

The construction <number>/<pattern>/ defines a quasi-pattern which matches the <number>th occurrence of <pattern> in a line. The construction -<number>/<pattern>/ defines a quasi-pattern which matches the <number>th occurrence of <pattern> from the end of a line. Quasi-patterns may be used in the place of patterns in E, S, ZL, and ZU commands.

Line Addresses

Valid Forms:

<number>
Ordinary line number.
$
Last line in buffer.
.
Current line in buffer.
+<number>
As first address, equivalent to ".+<number>". As second address in address pair, equivalent to first address plus <number>. If no <number>, equivalent to ".+1".
-<number>
As first address, equivalent to ".-<number>". As second address in address pair, equivalent to first address minus <number>. If no <number>, equivalent to ".-1".
/<pattern>/
First line after "." containing <pattern>. Search for <pattern> begins at line after ".", wraps around to top of buffer if necessary, ends at "." if <pattern> not found.
~/<pattern>/
First line after "." which does not contain <pattern>.
-/<pattern>/
First line before "." containing <pattern>. Search for <pattern> begins at line before ".", wraps around to bottom of buffer if necessary, ends at "." if <pattern> not found.
-~/<pattern>/
First line before "." which does NOT contain <pattern>.
<addr>
Symbol used for valid addresses above or address constructs below.
<addr>+<number>
Refers to the <number>th line after <addr>.
<addr><number>
Same as <addr>+<number>.
<addr>-<number>
Refers to the <number>th line before <addr>.
<addr>.
Refers to <addr>+1.
<addr>+/<pattern>/
Refers to first line after <addr> containing <pattern>. Search for <pattern> begins at <addr>+1, wraps around to the top of the buffer if necessary, and ends at <addr> if <pattern> is not found.
<addr>/<pattern>/
Same as <addr>+/<pattern>/.
<addr>~/<pattern>/
Refers to first line after <addr> not containing <pattern>.
<addr>-/<pattern>/
Refers to the first line before <addr> containing <pattern>. Search for <pattern> begins at <addr>-1, wraps around to the bottom of the buffer if necessary, and ends at <addr> if <pattern> is not found.
<addr>-~/<pattern>/
Refers to first line before <addr> not containing <pattern>.
^
Shorthand for ".-1".
<addr>^
Shorthand for "<addr>-1".
*
Shorthand for "1,$".
<addr>*
Shorthand for "<addr>,$".
&
Shorthand for ".+1,.+<pagesize>" where <pagesize> is set by the O+P command. If no <pagesize> has been set, & will generate ".+1,.+20".
<addr>&
This generates the pair of addresses "<addr>,<addr>+<pagesize>".
<addr>-&
This generates the single address <addr>-<pagesize>.

Buffer Programs

A program is invoked by the command line, "fred filename arg1 arg2 ..." where filename is the name of the file containing the program. If filename is not found under the current catalog, the FRED bootstrap looks for it under "/fred/filename" and then "fred/filename".

The arguments "arg1", "arg2", etc. (if any) are placed on separate lines in buffer "0". The specified file is read into buffer ".". The date is placed into buffer "d" in the numerical format "mm/dd/yy". The time is placed into buffer "t" in the numerical format "hh:mm". The current userid is placed in buffer "u". If there is an init file named "/fred/.init", FRED will execute those inits before it executes the commands it had read into buffer ".".

Language Limitations and Special Considerations

When reading from a file, FRED will not accept a record of longer than 2000 characters. Lines longer than 2000 characters are broken up into separate lines of 2000 characters each. An S command cannot lengthen any line beyond 2000 characters.

FRED uses the octal character \777 as a special internal character; for this reason, the character may not appear in input text.

If null lines are being supplied to fill a \R construction, and line feeds are used rather than carriage returns, every other line feed is ignored.

Copyright © 1996, Thinkage Ltd.