String length: Difference between revisions

Content added Content deleted
Line 323: Line 323:
70 NEXT x
70 NEXT x
80 PRINT LEN b$</lang>
80 PRINT LEN b$</lang>

Alternatively, the string might include control codes for backspacing and overwriting;

<lang zxbasic>10 LET a$=CHR$ 111+CHR$ 8+CHR$ 21+CHR$ 1+CHR$ 34</lang>
will produce an "o" character overprinted with a quotation mark, resulting in a "passable" impression of an umlaut. The above code will reduce this to two characters when the actual printed length is one. The other possible workaround is to print the string and calculate the character length based on the resultant change in screen position. (This will only work for a string with a character length that actually fits on the screen, so below about 670.)

<lang zxbasic>10 INPUT a$
20 CLS
30 PRINT a$;
40 LET y=PEEK 23689: LET x=PEEK 23688
50 PRINT CHR$ 13;32*(24-y)+33-x</lang>


==={{header|Commodore BASIC}}===
==={{header|Commodore BASIC}}===