Acorn Computers BBC Micro Model B w/8271 — Acorn BBC Micro Model B w/8271 User Guide Manual PDF (EN)

115 It is easy to join two strings together to make a long string by using the ‘string concatenation operator’ which is a plus sign. Its title sounds grand but its purpose is obvious – but quite different from its arithmetic use. 10 A$="NOTWITHSTANDING" 20 B$=LEFT$(A$,3) 30 C$=" LIKELY" 40 D$=B$+C$ 50 PRINT D$ >RUN NOT LIKELY The numeric function LEN can be used to count up the number of characters in a string – in other words how long it is. 10 A$="NOTWITHSTANDING" 20 X=LEN(A$) 30 PRINT X >RUN 15 LEN is very useful if you don’t know how long a string is going to be. For example in this palindrome testing program is copied backwards letter by letter into .

5 REPEAT 7 B$="" 10 INPUT "What would you like to reverse? " 'A$ 20 FOR T=LEN(A$) TO 1 STEP-1 30 B$=B$ + MID$(A$,T,1) 40 NEXT T 50 PRINT '"If you reverse"' A$'" you get" ' B$ 60 UNTIL A$="" The numeric function INSTR can be used to see if there is a particular letter (or group of letters) in another string. 10 A$="NOTWITHSTANDING" 20 B$="T" 30 X=INSTR(A$,B$) 50 PRINT X >RUN 3 You will notice that it finds that there is a T at position 3 in . Sometimes it is useful to be able to start the search further along the string. To do this you can add a third parameter which gives that position to start the search.