LEFT$

From C64-Wiki
Jump to: navigation, search
BASIC keyword
Keyword: LEFT$
Abbreviation: L, E, Shift+F
Type: Function
Token code: 200/$C8
Handling routine
in BASIC ROM:
46848–46891
$B700–B72B
List of all BASIC keywords


Remark: This article describes the BASIC function LEFT$ in BASIC V2 at the Commodore 64.

Typ: String Function 
General Programming-Syntax: LEFT$(<string>,<integer number>)

LEFT$ will be used for cutting strings into component parts beginning at the left side until to the indicated integer number. When we numerical value is 0, the outcome is a empty string (for example A$=""). When we indicated number is greater than the string, nothing will be cut.

The range of numerical values are 0 until 255. Outside the range - also negative or greater than 255 - the BASIC-error ?ILLEGAL QUANTITY ERROR IN line occurr. By using a wrong type of variable the BASIC-error ?TYPE MISMATCH ERROR in line appears. When the string or the numerical argument is missing, the BASIC-error ?SYNTAX ERROR IN line is viewed.

Examples[edit]

10 A$="SATURDAY MORNING"
20 B$=LEFT$(A$,8): PRINT B$ (SATURDAY will be cutting and print out)


10 A$="SATURDAY MORNING"
20 FOR X=0 TO LEN(A$)+1 
30 PRINT LEFT$(A$,X): NEXT X
BASIC V2.0 (second release) Commands

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