(rasa Doing things with words Most computers can examine the words stored in vanables and do vanous things with them. They can check the contents of a variable and see 1 itcontalnsa particular word or letter. This is useful for checking the | words input by someone using the program. Computers canalso rearrange the lettersor words ina difierent order and add them to letters inother vanables. Below you can find out how you do these things in | BASIC but not the ZX81, 4 | osi x you can leave -;. h 10 AS-"I AM STUPID outthe PRINT LEFTSIBS,4) 20 BS- "ONLY FOOLS THINK" ONLY 30 CS-BS:" "- AS PRINT LEFTSIBS,4) - RUN ONLY FOOLS THINK | AM STUPID On most computers, — You can add the contents You canalso add parts of of two variables like this. variables, like this. You need the space LEFT$(B$,4) means take the between guotation first four letters from theleft marks to leave a space ofB$. This tells the computer to take To tell the computer to use letters from the right you sa TD ONE o ee o o. —PmČmmemeAe£ee—, »- s-—— - the middle letters. The first use RIGHT$ with the name number tells it where to start - olthestring and the and the second tells it how '. numbers of letters you want. many letters to take. Note for Sinclair users PRINT A$(6 TO 11) STUPID PRINT B$(14 TO 16) 10 KS-"DING DONG 20 PRINT LEN'KS) RUN 10 This means take You canalso find out the letters numbers length ofa string -the number of letters, spaces and symbols it contains. To do this you use LEN, short for length. oči IF A$< "COMPUTER BOOK" what is LEFT$ (A$,8)? Codemaker program This program automatically puts words into code. Similar, but much more complex nam are used by intelligence services to write and crack codes. sČaBI z ena dij to understand this program is to write a secret message on a piece of per, then wor through the lines of the program carrying out the computer's tasks Your message and writing them down. S LET C$-"" | oa 1 LET D$-"" Sets up empry string variables 10 PRINT "TYPE IN A SHORT MESSAGE" 20 INPUT M$ 30 PRINT "NOW TYPE IN A SECRET This means the lengih of your NUMBER BETWEEN 2 AND";LEN(M$)- 1 message minus |. 40 INPUT N N (your secret number) letters from 50 LET A$- RIGHT$(M$,N) P——— the right of MS. a H The length of M$ minus N numbe 60 LET B$-LEFTSMS.LENOMS)-N) ] —— rartom balet oMi(Le ineros M$- A$4B$ — of the letters) 80 FOR I—1 TO LEN(M$) STEP s zalij Replaces the lerters in MS with AS BS. 90 LET C$-C$- MID$M3, 1, 1) From | to the number of letters in your message 100 NEXT | poe a aa na tni 110 FOR J<2 TO LEN(M$) STEP 2 sorepeated ine PYtukas cms lebar finan position | of (iz LET D$-D$ MID$(M4,J, 1) OZ oa a po NEXT J message up in twos, i.e. 2, 4, 6, etc. LET M$ | a z . .. . di — % s Ed DA a oj vegi V> SK IS vUg vz vsega kd BA zi DEI!