EXAMPLE PROGRAMS

2lower.str

This program takes a line of text as input on the command line and converts uppercase letters to lowercase ones. "./2lower.str ABC" should print "abc". This is merely a demonstration of case conversion in Stril.

2upper.str

This program takes a line of text as input on the command line and converts lowercase letters to uppercase ones. "./2upper.str abc" should print "ABC". This is merely a demonstration of case conversion in Stril.

Add-pim.str

This program creates new entries in an existing database file. It reads the entries generated by new-pim.str and prompts accordingly. Syntax: ./add-pim.str test1.pim

Bin2h.str

This program takes a binary number as input and converts it to hexadecimal. The length of the binary number has to be divisible by four. Example: ./bin2h.str 11111111 (should print FF, i. e. 255 in base 10).

Bin2o.str

This program takes a binary number as input and converts it to octal. The length of the binary number has to be divisible by three. Example: ./bin2o.str 111001 (should print 71, i. e. 57 in base 10).

Char2num.str

This program takes a single character as input on the command line and outputs the numerical value of that character. "./char2num.str A" should print "65".

Clear.str

This program clears the screen of your terminal by printing two backslash sequences. The first backslash command (\r[2J) clears the screen. The second backslash command (\r[90F) repositions your cursor to the first line if your terminal window has less than 90 lines. No parameters are required.

Cview.str

This program shows a form of ASCII art on the screen. It shares much of the code and the speed limitations with sview.str. Upper case letters are printed in green, numbers are printed in yellow, lower case letters are printed in blue and anything else is printed in white. The background colour is blue. Syntax: ./cview.str image.txt.

Echo.str

This is a replica of the standard *nix echo program. It simply prints the parameters it is fed on the command line. If you don't use any parameters, it prints nothing. The program understands backslash sequences, but you'll probably need to use double backslashes. That is a feature of your shell or command interpreter. It has nothing to do with echo.str.

Encrypt.str

This program takes a line of text as input on the command line and adds one to the value of each character. "./encrypt.str again" should print "bhbjo". This is merely a demonstration. The program does NOT generate secure encryption!

False.str

This is a replica of a standard *.nix shell programming utility. It does nothing unsuccessfully and terminates with exit code -1.

Fmt.str

This is a simple text formatter. Lines are broken after about 70 characters, but words and empty lines are left as they are. One carriage return per line is removed, thereby hopefully converting files to *nix format. Syntax: ./fmt.str file

G2pbm.str

This program takes a file containing Stril ASCII art (the edited output of gmake.str) as input and outputs a pbm image. The program writes to the screen, so you have to redirect the output to a file. Syntax: g2pbm.str image.txt > image.pbm.

Gmake.str

This program creates an ASCII art canvas of 22 lines with 60 characters per line. You have to redirect the output to a file. The resulting file can be edited with any text editor, but it is best to use a mono-spaced font. Syntax: gmake.str character > file.

Gview.str

This program shows a form of ASCII art on the screen. It shares much of the code and the speed limitations with Sview.str. Upper case letters are printed in half-bright, numbers are printed in bold letters and anything else is printed as a space. Syntax: gview.str image.txt.

H2bin.str

This program takes a hexadecimal number (0-9,a-f) as input on the command line and converts it to binary. "./h2bin.str ff" should print "11111111".

Keypress.str

This program works the same way as echo, but it waits for a single keypress when the optional argument has been printed. Syntax: ./keypress.str (arg)

Mirror.str

This program takes a line of text as input on the command line and creates a mirror image. "./mirror.str ABC" should print "CBA".

More.str

More.str is a featureless version of the *nix program with the same name. I reads from standard input and waits for user input each time 20 lines have been printed. Syntax: Some command | ./more.str

Motd.str

The program prints a message of the day and takes a single letter as input. Syntax: ./motd.str char.

New-pim.str

This program creates a new database file. You have to write the names of the sub-records when prompted. If you want the file to contain title, author, year and publisher, you write "Title" at the first prompt, "Author" at the second prompt and so on. When you are finished, you press enter on an empty line. Syntax: ./new-pim.str test1.pim

No.str

The program prints "n" for no in an eternal loop. It is the negation of yes, a standard *nix shell programming utility.

Num2char.str

This program takes a number as input on the command line and prints the corresponding character. The number has to be in the range 0-126. "./num2char.str 126" should print ~ (a tilde).

O2bin.str

This program takes an octal number (0-7) as input on the command line and converts it to binary. "./h2bin.str 70" should print "111000".

Read.str

This program changes your foreground colour to white and your background colour to blue. Then it reads one word at a time from standard input. It pauses two seconds between each word. Syntax: ./read.str < test.txt

Reader.str

This is a more advanced version of read.str. It reads from a file, not from standard input, and it needs to be fed a filename on the command line. Reader.str presents the file line by line, it can set and use bookmarks, and it can search the file for an expression.

Readline.str

This program reads lines from standard input and prints to the screen. Syntax: ./readline.str < test.txt

Reset.str

This program resets all terminal attributes by printing a backslash sequence (\rc). It also clears the screen.

Sview.str

This program colour codes Stril operators (<,|,\ and comma)to make it easier to spot errors. It writes byte by byte (could be improved), so it is rather slow. The speed is, however, not really an issue. Stril programs tend to be rather small. Syntax: sview.str program.str.

Sync.str

This program is actually the same as true.str. Stril calls sync before it exits. Syntax: ./sync.str

Text2html.str

This is the program that is used to generate the documentation of Stril. It depends on html.stl (a simple style-sheet). It is not meant as a general text to HTML converter, but it demonstrates that Stril is able to generate a subset of HTML. Text2html.str writes to standard output. Syntax: ./text2texts.str file

Text2text.str

This program can also be used to generate the documentation of Stril. It depends on txt.stl (a simple style-sheet). It is not meant as a general text formatter, but it demonstrates the text processing capabilities of Stril. Text2text.str combines the code base of fmt.str and text2html.str. It writes to standard output. Syntax: ./text2texts.str file

True.str

This is a replica of a standard *.nix shell programming utility. It does nothing successfully and terminates with exit code 0.

Unhtml.str

This program removes HTML tags from a file. It writes to standard output. The support for national characters is limited, but more could easily be added. "Less than" is also handled correctly. Syntax: ./unhtml.str file

View-pim.str

This program allows you to search and print database files generated by new-pim.str and add-pim.str. Only the first sub-record in each record can be searched. Syntax: ./view-pim.str test1.pim

Wait.str

This program does nothing successfully if you run it without arguments. If an argument is used, it waits for a number of seconds. That number is the value of the first character in the argument minus 48. "./wait.str D" should wait for 20 seconds since a capital D has the value of 68. Syntax: ./wait.str arg.

Yes.str

This program prints "y" for yes in an endless loop. It is a replica of a standard *nix utility that is often used in shell programming.