HP Pascal/iX Reference Manual (31502-90022)

9- 13
ABCDE 15
strpos
Usage
strpos
(s1, s2)
Arguments
s1
A string expression.
s2
A string expression.
Description
The function strpos
(s1, s2)
returns the integer index of the position of
the first occurrence of
s2
in
s1
. If
s2
is not found, zero is returned.
If the length of
s2
is zero, the result is 1.
NOTE Some HP Pascal implementations have the order of the two parameters
reversed. Also, your implementation may have a compiler option
that reverses the order of parameters.
Example
CONST
separator = ' ';
VAR
i: integer;
names: string[80];
BEGIN
.
names:= 'Jon Jill Ruth Marnie Bob Joan Wendy';
i:= strpos (names,separator); { i = 4 }
IF i <> 0 THEN
strdelete(names,1,i); { deletes first name }
.
i:= (strpos(names,'Ron')); { i = 0 }
END
strrpt
Usage
strrpt
(s, n)
Arguments
s
A string expression.
n
An integer expression indicating the number of repetitions
where
n
must be greater than or equal to zero.
Description
The function strrpt
(s, n)
returns a string composed of
s
repeated
n
times. If
n
is 0, a zero-length string is returned.