! declares a variable to be real - which means the integer part, and the portion to the right, of the
decimal point. Variables default to being real upon switch on. Real variables can take any value in
the range 2.9E-39 to 1.73+38.
$ indicates a string variable, where the contents may be a mixture of numbers, letters etc. In other
words an arbitrary collection of characters that are delimited by being enclosed within double quotes
” “. For example:
NAME$="BOB SMITH"
Using this in our evolutionary example, add line 6, and adjust line 60:
5 CLS
6 INPUT "What is your name";NAME$
10 INPUT "WHAT IS YOUR SALARY";SALARY
20 IF SALARY < < 10000 THEN GOT0 30 ELSE 40
30 PRINT "ASK FOR A PAY RISE": END
40 PRINT "ASK FOR A BIGGER CAR"
50 IF SALARY >30000 THEN PRINT
"and get a good accountant"
60 IF SALARY >25000 THEN PRINT
“. . . . and lend me a fiver ";NAME$
61 DAILY.RATE=SALARY/365:
PRINT "that's “;DAILY.RATE;" a day"
70 FOR n=1 to 5000: NEXT n:GOTO 5
run
Note a space has been added after fiver or the name would be butted hard up against fiver . Try it if
you don’t believe us! The semicolon ; at the end of PRINT or INPUT statement supresses the
computer’s desire to start a new line at the end of each such statement - unless told otherwise.
We can also work in the subject of integers by adding line 61. Just type it in, and the computer will
organise the program:
5 CLS
6 INPUT "What is your name";NAME$
10 INPUT "WHAT IS YOUR SALARY";SALARY
20 IF SALARY < < 10000 THEN GOT0 30 ELSE 40
30 PRINT "ASK FOR A PAY RISE": END
40 PRINT "ASK FOR A BIGGER CAR"
50 IF SALARY >30000 THEN PRINT
"and get a good accountant"
60 IF SALARY >25000 THEN PRINT
“. . . . and lend me a fiver ";NAME$
61 DAILY.RATE=SALARY/365:
PRINT "that's “;DAILY.RATE;" a day"
70 FOR n=1 to 5000: NEXT n:GOTO 5
run
Note that the delay in line 70 has been increased to 5000 now that there’s more to read on the
screen. The result of the daily rate calculation is untidy - you might as well round it, to an integer
value. Add line 62 . . . . . . . . .