A Mouthful for Every Occasion

See all articles from SYNC v2 n5
Author(s): Don Day
Publication: SYNC
Pub Details: SYNC v2 n5 (Volume 2, Issue 5)
Date: September/October 1982
Pages: 85-87

You can call up sensational headlines, forceful commands, whimsical statements, ageless wisdom, and irrelevant nonsense all at the push of a key on your Sinclair computer with the Mouthful program.

What the Program Does

Mouthful is a simple text manipulation program based on the old game of drawing words randomly from a list of assorted words. Strung together, the words make up an unpredictable and often hilarious phrase or saying.

By using the Sinclair computer in a unique way, Mouthful plays this old game in a new way. The program chooses a word from each of the three word lists (see Tables 1, 2, and 3) and prints the resulting phrase on your TV screen. You can generate new phrases as often as you please by pressing NEWLINE.

How to Use the Program

The program for Mouthful is in Listing 1. Type it into the computer carefully.

To begin the operation of the program, type GO TO 20 and hit NEWLINE. If the program is running properly, a string prompt (“[L]”) will appear in the upper left corner of the screen.

Now comes the big decision: What list will produce the phrase you want? Select Table 1 for oddball headlines, Table 2 for zany slogans, Table 3 for high-sounding utterances known as aphorisms (e.g., Necessity is the mother of invention).

Type in the list you have selected. Be careful to observe the spaces needed to pad the words into a ten character field. Press NEWLINE after the last word. This stores the words in a single array with proper spacing for random selection. Note that using Table 3 requires some program changes before you type in the list. The screen will go blank for a moment as the ZX80 does its prestidigitation.

The prompt in line 110 will appear and all you need to do is follow the prompts.

You can make up your own lists for the Mouthful program. The list must have exactly 15 words. No word can be longer than 10 letters, and, if the word is shorter, add spaces to fill out to 10 characters.

After you SAVE a program, use GO TO 100 and NEWLINE to begin execution of the program. Do not use RUN and NEWLINE or you will lose your list.

The program can be changed to use longer lists if you have more memory. Lists of 30 words or even more can be entered if array A (line 20) is made larger and the limit of I (line 300) is increased.

Listing 1. Mouthful (4K ROM).

 10 GO TO 100
20 DIM A(150)
30 INPUT A$
40 FOR N=0 TO 149
50 LET A(N)=CODE(A$)
60 LET A$=TL$(A$)
70 NEXT N
100 CLS
110 PRINT "PRESS N/L TO GENERAT
E PHRASE"
120 INPUT A$
130 PRINT
140 PRINT
150 PRINT
160 PRINT
170 LET N=0
180 GO SUB 300
190 PRINT "#";
200 LET N=1
210 GO SUB 300
220 PRINT "#";
230 LET N=2
240 GO SUB 300
250 PRINT
260 PRINT ,"AGAIN? (Y/N)"
270 INPUT A$
280 IF NOT A$="N" THEN GO TO 10
0
290 STOP
300 LET I=RND(4)-1
310 FOR M=0 TO 9
320 PRINT CHR$(A((N*40+I*10)+M)
);
330 NEXT M
340 RETURN

Table 1. Wacky Headlines. Table 2. “Yes, sir!” Slogans. Table 3. Words of Wisdom.

Table 1         Table 2         Table 3
#COMPUTER#      ##CONSUME#      ##BEAUTY##
BANK#CLERK      OBLITERATE      ##AVARICE#
GOVERNMENT      #ADVERTISE      #NECESSITY
#COMMITTEE      ##REWARD##      ##HONESTY#
PROSECUTOR      ##WELCOME#      ##COURAGE#
GENERATES#      HEALTHFUL#      ##SCOURGE#
NABBED#FOR      #MENACING#      INSTIGATOR
ELIMINATES      GANGRENOUS      ##REWARD##
RECOMMENDS      #LAVENDER#      #BLESSING#
#CONDEMNS#      HONORABLE#      #LOATHING#
HEADLINES#      VEGETABLES      INVENTION#
EXTORTION#      INTRUDERS#      HUMANITY##
EFFICIENCY      HORSEFLESH      ##APATHY##
MODERATION      BEHAVIOR##      DEDICATION
PRISONERS#      #VISITORS#      #AMBITION#

For Table 3 change Listing 1 as follows:

190 PRINT “#IS THE”;
220 PRINT “#OF#”

How the Program Works

When you press NEWLINE after typing in the list, Mouthful converts the characters into code equivalents which are stored in array A. The trick to breaking this array into three separate lists lies in manipulating the index variable N. This is done by using a multiplier to force N to “see” only that part of the array you want it to. On the first call for a word, the loop index N is set to 0, and a random number is assigned to I. Thus, if I is 3, then the word chosen begins at 0*40 plus 3*10, or at A(30). On the second call for a word, N is set to 1 and I is randomly reassigned. Thus, if I is 5, then the word begins at 1*40 plus 5*10, or at A(90). A third call prints out a random third word by the same technique, and the phrase is finished.

Notes

The following line notes point out some of the program features.

20-70: Load the word lists into the program as a single variable, A$.

100: Starts main portion of program; return point from line 280.

130-160: Help format display.

180, 210, 240: Calls for the random words.

290: End of main portion.

300: Begins subroutine for word selection and printing.

340: Return to main program.

8K ROM Changes

Listing 2 gives the translation for the 8K ROM.

The 8K program can also be made to run continuously by deleting lines 110 to 290 in Listing 2 and substituting lines 110 to 290 in Listing 3.

The 8K ROM version requires over 1K RAM to run as shown; however, the continuously running version can be squeezed into 1K RAM by shortening array A to about 90 elements and adjusting line 320. Short words can be used to maintain the variety of phrasing.

Screen display: "PRESS ENTER TO GENERATE PHRASE / BANK CLERK ELIMINATES HEADLINES / AGAIN? (Y/N)"
Screen display: "PRESS ENTER TO GENERATE PHRASE / BANK CLERK ELIMINATES HEADLINES / AGAIN? (Y/N)"

So . . .

Set this program up and have it running at your next party. Your popularity (or perhaps even your notoriety) will never be the same again!

Listing 2. 8K ROM.

  10 GOTO 100
20 DIM A(150)
30 INPUT A$
40 FOR N=1 TO 150
50 LET A(N)=CODE A$
60 LET A$=A$(2 TO )
70 NEXT N
100 CLS
110 PRINT "PRESS ENTER TO GENER
ATE PHRASE"
120 INPUT A$
130 PRINT
140 PRINT
170 FOR N=0 TO 2
180 GOSUB 300
190 PRINT " ";
200 NEXT N
210 PRINT
260 PRINT TAB 8;"AGAIN? (Y/N)"
270 INPUT A$
280 IF NOT A$="N" THEN GOTO 100
290 STOP
300 LET I=INT (RND*4)+1
310 FOR M=0 TO 9
320 PRINT CHR$ (A((N*40+I*10)+M
-9));
330 NEXT M
340 RETURN

Listing 3. Lines for 8K ROM Continuous Running.

 100 CLS
110 PRINT
170 FOR N=0 TO 2
180 GOSUB 300
190 PRINT " ";
200 NEXT N
210 PAUSE 120
290 GOTO 100

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.