Sinclair QL Beginner's Manual page 25

Hide thumbs Also See for QL:
Table of Contents

Advertisement

10 LET weekday$ = "FIRST" 
20 LET word$ = "OF" 
30 LET month$ = "FEBRUARY" 
40 LET length1 = LEN (weekday$) 
50 LET length2 = LEN (word$) 
60 LET length3 = LEN (month$) 
70 LET sum = length1 + length2 + length3 
80 LET average = sum/3 
90 PRINT average 
RUN 
The symbol / means divided by. The output or result of running the program is simply:
5
And there are eight internal pigeon holes involved:
weekday$
word$
month$
FEBRUARY
If you think that is a lot of fuss for a fairly simple problem you can certainly shorten it. The shortest
version would be a single line but it would be less easy to read. A reasonable compromise uses the
symbol "&" which stands for the operation:
Join two strings
Now type:
NEW 
10 LET weekday$ = "FIRST" 
20 LET word$ = "OF" 
30 LET month$ = "FEBRUARY" 
40 LET phrase$ = weekday$ & word$ & month$ 
50 LET length = LEN(phrase$) 
60 PRINT length/3 
RUN 
The output is 5 as before but there are some different internal effects:
Weekday$
FIRST
FIRST
OF
Length
length1
5
length2
2
length3
3
sum
15
average
5
15

Advertisement

Table of Contents
loading

Table of Contents