Sinclair QL Beginner's Manual page 26

Hide thumbs Also See for QL:
Table of Contents

Advertisement

Word$
OF
Month
FEBRUARY
Phrase$
FIRSTOFFEBRUARY
There is one more reasonable simplification which is to use READ and DATA instead of the first three
LET statements. Type:
NEW 
10 READ weekday$, word$, month$ 
20 LET phrase$ = weekday$ & word$ & month$ 
30 LET length = LEN(phrase$) 
40 PRINT length/3 
50 DATA "FIRST","OF","FEBRUARY" 
RUN 
The internal effects of this version are exactly the same as those of the previous one. READ causes
the setting up of internal pigeon holes with values in them in a similar way to LET.
IDENTIFIERS AND STRING VARIABLES
Names of pigeon holes, such as:
weekday$
word$
month$
phrase$
are called string identifiers. The dollar signs imply that the pigeon holes are for character strings.
The dollar must always be at the end.
Pigeon holes of this kind are called string variables because they contain only character strings
which may vary as a program runs.
The contents of such pigeon holes are called values. Thus words like 'FIRST' and 'OF' may be values
of string variables named weekday$ and +word$
RANDOM CHARACTERS
You can use character codes (see Concept Reference Guide) to generate random letters. The upper
case letters A to Z have the codes 65 to 90. The function CHR$ converts these codes into letters. The
following program will print a letter B.
NEW 
10 LET lettercode = 66 
20 PRINT CHR$ (lettercode) 
RUN 
The following program will generate trios of letters A, B, or C until the word CAB is spelled
accidentally.
NEW 
10 REPeat taxi
20 LET first$ = CHR$(RND(65 TO 67))
30 LET second$ = CHR$(RND(65 TO 67))

Advertisement

Table of Contents
loading

Table of Contents