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

116 10 A$="NOTWITHSTANDING" 20 B$="T" 30 X=INSTR(A$,B$,4) 50 PRINT X >RUN 6 If no match is found then INSTR returns zero. 10 A$="NOTWITHSTANDING" 20 B$="Z" 30 X=INSTR(A$,B4,4) 50 PRINT X >RUN 0 This looks like the elements of the game called hangman! But first three more string related functions. It is possible to make a string containing many copies of another string by using the string function STRING$ . So to make a string containing 20 copies of ” ABC ” we write:

10 A$="ABC" 20 B$=STRING$(20,A$) 30 PRINT B$ >RUN ABCABCABCABCABCABCABCABCABCABCABCABC ABCABCABCABCABCABCABCABC 10 A=45:B=30 20 A$=STR$(A) 30 B$=STR$(B) 40 PRINT A+B 50 PRINT A$+B$ >RUN 75 4530 > There is also a function STR$ which converts a number into a string. ie line 40 treats A and B as numbers and line 50 as string characters. Note that STR$ is affected by the special variable @% if this has been set (see chapter 10). The opposite function is VAL . This extracts the number from the start of the string, which must start with a plus + or minus - sign or a number. If it