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 at the Commodore 64.
Typ: Numeric Function General Programming-Syntax: LEN(<String>)
The function LEN returns the number of characters in a string. This value is always in the range from 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 then 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 could never exceed the length of 255
In absence of any numeric argument or with more than one parameter leads to 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