Instr – Remote Processing CAMBASIC User Manual

Page 98

Advertising
background image

Comm ands - 65

INSTR

Function

SYNTAX:

a = INSTR(n,string,substring)

PURPOSE:

Returns the position of the first occurrence on a sub-string within a string.

REMARK S:

The par ameter n spe cifies where the sear ch is to start in the string. A “ 1” signifies the leftmo st
position in the string. This para meter is not optional. Its range is 1 to 252.

string is a string constant or string variable that is to be searched.

substring is the string variable or constant to be searched for.

If n is greater than the length of string or if string is null or if substring cannot be found, INSTR
returns zero. If substring is null, INST R return s n or one.

RELATED:

L E F T $ , R IG H T $ , L E N an d M ID $

EXAMPLE:

10 A$="BOOHOO"
20 B$="HOO"
30 PRINT INSTR(1,A$,B$)
RUN
4

ERROR:

< Illegal argument> – if n < 1

Advertising