ZX 81 - BASIC Programming

Sinclair ZX Spectrum
Chapter 7.2 - Strings

Exercises

1. Type

LET A$="2+2"

& then

PRINT A$;" = ",VAL A$

Try changing A$ to more complicated things & doing the same, e.g.

LET A$="ATN 1*4"

(The answer here should be .)

2. The string "" with no characters is called the empty or null string. It is only string whose length is 0. Remember that spaces are significant and an empty string is not the same as one containing spaces.

Do not confuse it with the quote image, "" (a single token, shifted Q). This is a special device to get over the fact that you cannot write an ordinary string quote in the middle of a string (why not?). When the quote image appears in a string that has its quotes at the end (for instance in the listing of a program), it shows up as two quote symbols, to distinguish it from the ordinary quote; but when it is displayed by a PRINT statement, it is as just one quote symbol.

Try

PRINT "X";"";"X",""""."""";"";""""

3. If you enjoy humiliating computers, type

PRINT "2+2 = ";2+1

Sinclair ZX Spectrum

  Previous Page Back Next Page