INSTR |
instr is used to find a given sub-string in a character string, from a character of a given position in the string.
instr( rank, string, sub_string )
|
Element |
Description |
Restrictions |
|
rank |
Integer type expression giving the position corresponding to the 1st character in the string from which the sub-string search begins. |
position > 0 |
|
string |
Char type expression representing the string in which the search is carried out. |
None. |
|
sub_string |
Char type expression representing the sub-string searched for. |
None. |
# Search for an 'ABC' character string in a
given string;
# with the following parameters this
programme displays 3
Infbox num$(instr(1,"ABC is in an alphabetical list",'ABC'))
# Count the number of MOT words in a TEXTE
text
# and place the result in the variable
CPT
CPT = -1 : I = 0
Repeat I = instr(I+1, TEXTE,
MOT) : CPT += 1 : Until I = 0
instr looks for sub_string in string from the position and gives the position (in number of characters) of the first character for the sub-string searched for. If the sub-string is not present, or if position <= 0, instr returns 0.
|
Error |
Description |
|
ERMODE (10) |
- position is not a numerical type. |
|
ERDOM (50) |
position < 0 |
LEFT$ - RIGHT$ - STRING$ - SPACE$ - SEG$ - MID$ - VIREBLC
|
|