ZX80 4K ROM string length
Posted: Sun Jan 28, 2018 5:09 pm
Here's a sub routine that will count the length of a string (including example).
The B$ variable is used as a buffer (as ZX80 4K ROM BASIC doesn't have the same string handling routines as the 'New ROM') as the original string (A$) is being reduced by one character in the sub routine (line 540).
Regards,
Shaun.
Code: Select all
10 LET A$="HOW LONG IS A PIECE OF STRING?"
20 LET B$=A$
30 GOSUB 500
40 PRINT "LENGTH IS ";L
100 STOP
500 REM STRING LENGTH
510 LET L=0
520 IF B$="" THEN GO TO 560
530 LET L=L+1
540 LET B$=TL$(B$)
550 GO TO 520
560 RETURN
Regards,
Shaun.