User manual

mikroPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
678
strspn
Prototype
function strspn(var s1, s2 : string) : word;
Description The function searches the string s1 for characters not found in the s2 string.
The function returns the index of rst character located in s1 that does not match a character in s2. If
the rst character in s1 does not match a character in s2, a value of 0 is returned. If all characters in
s1 are found in s2, the length of s1 is returned (not including the terminating null character).
Example
txt := ‘mikroElektronika’;
txt_sub := ‘mikr’;
res := strspn(txt,txt_sub); // routne returns 4
strncmp
Prototype
function strncmp(var s1, s2 : string; len : word) : integer;
Description The function lexicographically compares the rst len characters of the strings s1 and s2 and returns
a value indicating their relationship:
Value Meaning
< 0 s1 “less than” s2
= 0 s1 “equal to” s2
> 0 s1 “greater than” s2
The value returned by the function is determined by the difference between the values of the rst pair
of words that differ in the strings being compared (within rst len words).
Example
txt := ‘mikroElektronika’;
txt_sub := ‘mikr’;
res := strncmp(txt_sub,txt,3); // compares the rst 3 characters from the
string ‘txt’ with the sting ‘txt_sub’ and returns a difference
strstr
Prototype
function strstr(var s1, s2 : string) : word;
Description The function locates the rst occurrence of the string s2 in the string s1 (excluding the terminating
null character).
The function returns a number indicating the position of the rst occurrence of s2 in s1; if no string was
found, the function returns 0xFFFF. If s2 is a null string, the function returns 0.
Example
txt := ‘mikroElektronika’;
txt_sub := ‘mikr’;
res := strstr(txt_sub,txt);