Sample Programs

INTERACT

This program can be used to try executing simple one liners, interactively in SNOBOL4. This is a great help when you are just learning SNOBOL4. INTERACT.BAT is a batch file which invokes SNOBOL4 as required. Just use the following command:

INTERACT Try entering the following two lines which will print out all of the substrings of 'HELLO THERE' (remember to type a blank in column one because they don't have any labels): &FULLSCAN = 1 'HELLO THERE' ARB $ OUTPUT FAIL :(END) The last line causes the INTERACT program to end. Another way to end the program is press the Ctrl-Z keys to give an end of file indication, or type the label END in column one. Also, remember to enter the above lines in upper-case because SNOBOL4 names are case sensitive.

ELIZA

ELIZA in a program to be run interactively and permits one to be diagnosed by the famous computer psychiatrist. This program needs more than 128K of storage to run. Just type the following command:

ELIZA

ENGLISH

This program recognizes English sentences which follow a simple grammar. Use the following command to run the program

SNOBOL4 ENGLISH

SELFREPR

This is the shortest known self reproducing SNOBOL4 program. To run this program and put the reproduced copy in a disk file called "CHILD.SNO", use the command:

SNOBOL4 SELFREPR 7=CHILD.SNO

XREF

This program produces a cross reference listing of a SNOBOL4 program to the degree that this is possible. The program is read from unit 1 and the listing is written to unit 6. To run the cross reference program against the ENGLISH.SNO program above and print the output, use the command:

SNOBOL4 XREF 1=ENGLISH.SNO 6=LPT1:

EXPAND

This program reads a file and looks for lines which have the form:

.INCLUDE filename The content of the file "filename" replaces this "include" and the resulting expanded output file is written to output unit 2. "Includes" can be nested up to 7 levels deep. That is, "includes" are also processed from the inserted file. The EXPAND program is useful for inserting common subroutines into a source file just before running it. This program can also be used as a starting point for writing some sort of macro-expansion facility. To expand a source file, use the command: SNOBOL4 EXPAND 1=sourcefile 2=resultfile

Prior Page, Next Page, First Page of the Minnesota SNOBOL4 Reference