User manual

590
mikoPascal PRO for PIC32
MikroElektronika
strncpy
strspn
strncmp
Prototype
procedure strncpy(var s1, s2 : string; size : word);
Description The function copies at most size characters from the string s2 to the string s1. If s2 contains fewer
characters than size, s1 is padded out with null characters up to the total length of the size
characters.
Example
txt := ‘mikroElektronika’;
txt_sub := ‘mikr’;
strncpy(txt,txt_sub,4); // copies rst 4 characters form the string ‘txt_sub
to ‘txt’
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
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