Smple
Procedures
ANALYSIS
We
will
write a program
to
produce
ten
buzzv.ord
phrases.
The
stages
of
the program
are:
•
Store
the words
In
three string
arrays.
2 Choose three random numbers which
will
be the subscripts
of
the array variables.
3
Print the
phrase.
4 Repeat 2 and 3
ten
times.
DESIGN
VARIABLES
We
identify three arrays
of
which the
first
two
will
contain adjectives or words used as
adjectives
- describing words. The third array
will
hold the nouns. There are
13
words
in
each section and the longest word has
16
characters including a hyphen.
PROCEDURES
We
use three procedures
to
match the jobs Identified
store_data stores the three
sets
of
thirteen words
geL
random gets three random numbers
In
range 1
to
13.
make_phrase prints a phrase.
Array
adjec1$(13,12)
adJec2$(13,16)
noun$(13,15)
Purpose
first adjectives
second adjectives
nouns
•
34
MAIN PROGRAM This
is
very simple because the main work
is
done
by
the procedures.
Declare (DIM) the arrays
Store_data
FOR
ten
phrases
geLrandom
make_phrase
END
Program 1
DO
REMa
rk
************
110
REMark *
Buzzword
*
120
REMark
************
130
DIM
adjecl$(13,12),
adjec2$(13,16),noun$(13,15)
140
store
data
150
FOR
phrase
= 1
TO
10
160
.
get
random
170
make
phrase
180
END
FORphrase
190
REMark
**************************
200
REMark *
Procedure
Definitions
*
210
REMark
**************************
220
DEFine
PROCedure
store
data
230
REMark
***
procedure-to
store
the
buzzword
data
***
240
RESTORE
420
250
FORitem=1T013
260
READ
adjecl$(item),
adjec2$(item),noun$(item)
270
END
FOR
item
280
END
DEFi ne
290
DEFine
PROCedure
get
random
300
REMark
***
procedure
to
select
the
phrase
***
310
LET
adl
=
RND(l
TO
13)
320
LET
ad2 =
RND(l
TO
13)
330
LET n =
RND(l
TO
13)
340
END
DEFine
350
DEFine
PROCedure make
phrase
360
REMark
***
procedure
to
print
out
the
phrase
***
370
PRINT I
adjec1$(ad1l
I
adjec2$(ad2)
I
noun$(n)
12/84
•
•