INSTR()
This page was last modified 19:26, 27 January 2018 by Mars2000you. Based on work by NYYRIKKI and Gdx and others.

Contents

Effect

Returns the position of the first occurrence of a B$ substring in A$ string, starting from an optional offset (x).

Remark: For strings with Japanese or Korean characters, you need to use CALL KINSTR.

Syntax

INSTR([x,] A$,B$)

Range

INSTR accepts an offset (x) between 1 and 255 - Default value is 1.

Example

10 PRINT INSTR("I like MSX!","MSX");
 
RUN
8

Special values

INSTR will return
- value (x) if B$ substring is empty and offset (x) is not larger as the length of string A$ and A$ string is not empty
- value 0 if A$ string is empty OR B$ substring is not found in A$ string OR offset (x) is larger as the length of string A$

Related to

CALL KINSTR, LEN

Compatibility

MSX-BASIC 1.0 or higher