LEN
BASIC keyword | |
Keyword: | LEN |
Abbreviation: | – |
Type: | Function |
Token code: | 195/$C3 |
Handling routine in BASIC ROM: |
46972–46986 $B77C–B78A |
List of all BASIC keywords |
Remark: This article describes the BASIC command LEN in BASIC V2 of the Commodore 64.
Type: Numeric Function General Programming-Syntax: LEN(<String>)
The function LEN returns the number of characters in a string. This value is in the range 0 to 255.
If the argument does not result into a string value the BASIC error ?TYPE MISMATCH ERROR appears.
If the parameter expression evaluates to a string with more than 255 characters the BASIC error ?STRING TOO LONG occurs. It is to be noted that this is not part of the LEN function itself. Any given string can not exceed a length of 255 characters.
In the absence of any numeric argument or with more than one parameter results in a ?SYNTAX ERROR.
Examples[edit | edit source]
A$="The output has got this number of chars:" PRINT A$;LEN(A$) PRINT "The left half: "; LEFT$(A$,LEN(A$)/2)
produces the output:
The output has got this number of chars: 40 The left half: The output has got t
ABS | AND | ASC | ATN | CHR$ | CLOSE | CLR | CMD | CONT | COS | DATA | DEF | DIM | END | EXP | FN | FOR | FRE | GET | GET# | GOSUB | GOTO | IF | INPUT | INPUT# | INT | LEFT$ | LEN | LET | LIST | LOAD | LOG | MID$ | NEW | NEXT | NOT | ON | OPEN | OR | PEEK | π | POKE | POS | PRINT | PRINT# | READ | REM | RESTORE | RETURN | RIGHT$ | RND | RUN | SAVE | SGN | SIN | SPC | SQR | STATUS/ST | STEP | STOP | STR$ | SYS | TAB | TAN | THEN | TIME/TI | TIME$/TI$ | TO | USR | VAL | VERIFY | WAIT