BOOTSTRAP - the FRED Bootstrap program.

The Bootstrap program used by FRED is given below. Following the actual program, we will give a brief description of how the program works. (Note that the line numbers do not occur in the real Bootstrap program; we include them here merely as convenient labels.)

```"FRED Bootstrap Program
"
b(d)a mm/dd/yy\F "1
b(t)a hh:mm\F "2
b(u)a useridxxxxxx\Fs/ // "3
o+t4 b(f)\$r \S(u)/fred/.init, "4
jt jp'\S(u)/fred/.init:' y je "5
b(0)\B(f)zd(f) "6
b(0)a "\R "7
\Fk(.)s/ \O*/\C "8
/\$t/\O^\O\$/jfd "9
1d*t/\O./ "10
jt o-q n(f):0 zd(0)zd(.)zd(u)zd(t)zd(d)je/Fred/ "11
.m(f)b(.) "12
\$r \S(f),\S(u)/fred/\S(f),library/fred/\S(f),fred/\S(f),\S(f) "13
jt jp'\S(f):' y je "14
n(f):0 zd(f)b(0)o-q "15
\B(.) "16
qq "17```

Explanation of Bootstrap

"1
puts the date into buffer (d) in the numerical format mm/dd/yy (month/day/year).
"2
puts the time in buffer (t) in the form hh:mm (hour:minute).
"3
puts the user's userid in buffer (u) and deletes any trailing blanks.
"4
sets the tab stops at positions 5, 9, 13, etc. It then goes to buffer (f) and reads the user's init file into (f). The comma at the end of the line ensures that the condition register will be set to TRUE even if the init file is not found. However, if there is some actual error in reading the file, the condition register will be set FALSE.
"5
If the condition register is TRUE, the rest of the line is not executed. If the condition register is FALSE, there must have been an error trying to read the init file. The bootstrap therefore prints out the name of the init file and uses the Y command to print out the error that occurred. It then uses JE to quit the bootstrap process.
"6
The program switches to buffer (0) and executes the init file that is in (f) using the \B construction. It then deletes the init file contents from buffer (f). If the user didn't have an init file, the \B(f) simply inserts the contents of an empty buffer into the input stream and therefore the \B construction does nothing.
"7
Reads the command line fred filename arg1 arg2 ... into buffer (0) using the \R stream directive. Note that it puts a double quote " at the beginning of the line so the line will be taken as a comment.
"8
The \F beginning this line ends the input into buffer (0). The command line is copied into buffer (.) and then the buffer (0) copy is broken up into separate lines by substituting every space with a nl character. The \O in front of the * tells FRED to use the special pattern meaning of * even if the user has turned off this meaning in the init file. The \C at the end of the line tells FRED to treat the nl literally, rather than as a line delimiter.
"9
The / that begins the line ends the S command from the previous line. The T command tests the last line in buffer (0) to see if it is null. If so, it is deleted.
"10
deletes the first line of (0). (This is the single word fred that began the command line.) The T command tests to see if there is anything left in the buffer. The condition register will be set TRUE if the buffer actually contains material and FALSE if it is empty.
"11
The JT command will skip the rest of the line if the T command sets the condition register TRUE, i.e. if there is something in buffer (0). If the buffer is empty, the rest of the line is executed. FRED turns off the Quit option, deletes everything in all the buffers created so far, and exits to command level with the message Fred.
"12
The rest of the buffer is only executed if FRED is expected to execute a program. The first line in buffer (0) (the filename in the command line) is moved to buffer (f). (.) is then made the current buffer. Note that (.) already contains the command line copied from (0) in line "6. Since there is a double quote before this command line (inserted in line "7), the line will be treated as a comment when (.) is executed.
"13
(This line has been broken in two so it fits on the page.) FRED attempts to read the file containing the program to be executed. The file's name is stored in buffer (f) so \S(f) should be the file's name. However, the file can be stored under a variety of catalogs, so the read command needs a read list to check all the possibilities. At the end of the list is the original file name. This means that if none of the files can be found, the last error message will be the one associated with the filename that the user gave, not a file under some other catalog.
"14
If the condition register is TRUE, one of the read operations was successful; otherwise, an error message is required. FRED prints the filename given by the user plus the error message provided by the Y command. The bootstrap program then terminates with JE.
"15
This line is executed if the file containing the FRED program has been found and read into buffer (.). The buffer (f) containing the command line is deleted and the Quit option is turned off. Also, the program changes to buffer (0) (which is where buffer programs expect to start).
"16
Finally the bootstrap is ready to execute the program that has been read into buffer (.). It does this using a \B stream directive.
"17
After the program has been executed, FRED terminates with a QQ.