We have provided several complete applications written in JForth. They can be used either directly from JForth or they can be cloned and used as CLI commands. Some of them demonstrate how to parse the command line, how to handle input errors and print "usage" information. The file names all end with ".f" to distinguish the Forth source file from the cloned image file. These files can be found on the "JA:" logical volume.
Please see the chapter on Clone for instructions on how to clone these applications.
Converts every Carriage Return in a file to a Line Feed. This is handy if you get a file from some unfortunate Macintosh user.
DIAL is a CLI based utility that will look up and dial telephone numbers through your modem. All you have to do is enter in a CLI:
DIAL FRED
then pick up the phone and wait for Fred to answer. DIAL will search a text file containing names and phone numbers. When it finds a match it opens the SER: device and send a Hayes compatible message to your modem to dial. DIAL was written as a shell command because a mouse driven interface would take longer to use then just dialing the phone directly.
To install DIAL you must:
1) Copy DIAL to your C: directory or other command directory.
2) Set your serial preferences to match your modem. Eg. 1200 baud, 8 data bits, etc.
3) Create a file called S:PHONELIST containing names and phone numbers. Names and phone numbers cannot have spaces inside them. For example:
JOE 1(707)555-1212 <-- GOOD
FRED FLINTSTONE 1 (707) 555-1234 <-- BAD
There are two ways to do this. One is using a text editor. The other is to use the ADD option of DIAL. For example:
DIAL ADD WILMA 1(415)555-9876
The above will add WILMA's name to your phone list. If the phonelist file does not exist, DIAL will create it. To delete names, or to change names, just edit the file using a normal text editor like EMACS or Textra. You can optionally specify a filename other than S:PHONELIST. For example:
DIAL IRMA MYSTUFF:MYLIST
Since that would be more typing than just dialing it yourself, I recommend making an alias as follows:
ALIAS DL DIAL [] MYSTUFF:MYLIST
Put that alias in your S:SHELL-STARTUP file.
Note that DIAL.f is shareware. If you bought JForth then ignore that. Consider yourself paid up. Please feel free to give a cloned version of DIAL to a friend. Just make sure you also give the Dial.README file which contains this documentation and information on the shareware aspects of Dial.
This application can be used to automatically generate simple documentation from a file. It scans a file and prints any line that has a character in the first column, is not a comment, and has a stack diagram on it. Thus the following lines would be printed if they occurred in a file.
: ADD1 ( N -- N+1 , add one to a number )
and
VARIABLE NUM-FOO ( -- addr , number of foos)
and
: ADDEM { aa bb -- aa+bb , add em up }
The word which should be cloned is:
: DOCU.FILE ( <filename> -- , document file )
This application reads an IFF file containing a brush and outputs JForth compatible source code. Thus you can use DPaint to create images and use them in your programs as gadget images. Clone this program then enter:
DumpBrush >outfile brushfile
This scans an IFF file and prints out the contents of the chunks it encounters.
This is the program we used to convert the Amiga DOS include files from 'C' code to JForth compatible code. See the chapter on Amiga Libraries and Structures for more information.
PRINT will output a file to a printer. It prints the file name, page number, and date on each page. It will also put line numbers on each line and skip over page perforations. PRINT uses the left and right margins set in preferences to tell whether a line will wrap around. Thus, lines that wrap will not mess up the page breaks. You can turn off the line numbers using the "-n" option. You can set the number of spaces for a tab using the "-t#" option. The default tab spacing is 8 spaces between tabs. To print a file called MYSOURCE without line numbers and with tabs set to 6 spaces, enter:
PRINT MYSOURCE -N -T6
If you want to send the output to a file instead of the printer, give that filename after the source file. For example:
PRINT MYSOURCE OUTFILE
You can use this application to scare your friends or to control command files. RUDE will read a quoted string from the command line and display it in an Alert just like a GURU Meditation Error. The sight of these messages is enough to send a chill down the spine of most Amiga users.
Rude asks you to hit the left button for Yes and the right for No. A Yes will return 5 which can then be used to control the command file. Here is a sample Amiga DOS command sequence (not Forth).
RUDE "Should I install TextMangler 3.4?"
IF WARN
RUN TextMangler
ENDIF
SORTMERGE will take two presorted files and merge the output into a third file in sorted order. This application is useful for adding new data to a large presorted file. It can be handy when used with DOCU.FILE to create quicky documentation of a large multi-file project. Use the Amiga DOS SORT command to presort the input files.
SORTMERGE infile1 infile2 outfile
This JForth program parses the next word in the input stream and pronounces it in decimal-quantified form. For example, the "Say" command, as furnished by Commodore, would pronounce 123 as "one, two, three", whereas this program will say "one hundred and twenty-three".
saynum 123
saynum 1989
This very simple terminal program can be used as a starting point for a fancier terminal program.
This JForth program examines two directories, then copies everything from <srcdir> to <destdir> that meet the specified criteria. This is useful for maintaining backups of projects on floppies. UPDATE was written by Mike Haas for us at Delta Research as we worked on JForth on multiple Amigas. We could merge our work by updating to a central computer.
Usage:
Update SourceDir DestDir [-date|-size -list -noask -both]
-date = SourceDir/file is later than DestDir/file (default)
-size = SourceDir/file is different size than DestDir/file
-list = Don't really copy, just list the files that WOULD.
-noask= Don't ask the user to verify input
-both = Update only those files that exist in BOTH directories
-all = Check all files in the directory and any subdirectories.
Only the first letter of the option is required. Here is an example that updates everything from a hard disk resident volume called MYWORK: to a floppy in DF1:.
UPDATE MYWORK: DF1: -N -A
This is very similar to the UNIX wc command except it gives you all the information at once. The main word is called WC and is used like this:
WC filename