Other BASICs have LEFT$, RIGHT$ and MID$ functions; the ZX81 uses slices like A$(1 TO 3) instead. This program asks for a string four times and prints the result of each translation: the left part, the right part, a middle part, and the string without its first character (the ZX80’s TL$).
Use strings longer than seven characters. It ends with PROGRAM COMPLETED.
Published in Syntax August 1982 (String Function Translation for 8K).
Source Code
10 REM "STRING FUNCTIONS"
20 REM ZX80/8K ROM
30 REM ART BUMPUS
50 REM LEFT$ (A$,N)
60 GOSUB 500
70 LET N=7
80 REM PRINTS UP TO 7TH CHAR.
90 LET B$=A$( TO N)
100 PRINT B$;"""LEFT$(A$,N)"""
110 REM RIGHT$ (A$,N)
120 GOSUB 500
130 LET N=7
140 REM PRINTS FROM 7TH TO END
150 LET B$=A$(N TO )
160 PRINT B$;"""RIGHT$(A$,N)"""
170 REM MID$ (A$,N1,N2)
180 GOSUB 500
190 LET N1=7
200 LET N2=1
210 LET N3=N1+N2
220 REM PRINTS 1 CHAR. FROM THE 7TH
230 LET B$=A$(N1 TO N3)
240 PRINT B$;"""MID$(A$,N1,N2)"""
250 REM TL$(A$)
260 GOSUB 500
270 LET B$=A$(2 TO )
280 REM THIS DROPS THE 1ST CHAR.
290 PRINT B$;"""TL$(A$)"""
300 PRINT "PROGRAM COMPLETED"
310 STOP
500 INPUT A$
510 PRINT A$;"=";
520 RETURNNote: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
