INSTR

From C64-Wiki
Jump to navigationJump to search
BASIC keyword
Keyword: INSTR
Abbreviation: IN Shift+S
Type: Function
Token code: UNK
Handling routine
in BASIC ROM:
UNK
List of all BASIC keywords


Remark: This article describes the BASIC function INSTR in in Commodore BASIC V3.5 or higher.

Type: INTEGER Function 
General Programming-Syntax: INSTR(<string 1>, <string 2>[,starting-position])

INSTR returns the position of string 2 within string 1 at or after the starting-position.

The starting-position defaults to the beginning of string 2. If no match is found, a value of 0 is returned.

Examples[edit | edit source]

S1$="SUPERCALIFRAGILISTICEXPIALIDOCIOUS"
S2$="FRAG"
PRINT INSTR(S1$,S2$)

returns 10

S1$="SUPERCALIFRAGILISTICEXPIALIDOCIOUS"
S2$="FRED"
PRINT INSTR(S1$,S2$)

returns 0

S1$="SUPERCALIFRAGILISTICEXPIALIDOCIOUS"
S2$="C"
PRINT INSTR(S1$,S2$)

returns 6

S1$="SUPERCALIFRAGILISTICEXPIALIDOCIOUS"
S2$="C"
PRINT INSTR(S1$,S2$,7)

returns 20

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