Mikroelektronika MIKROE-724 データシート

ページ / 726
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
677
strcat2
Prototype
sub procedure strcat2(dim byref l, s1, s2 as string)
Description The procedure adjoins string 
s2
 at the end of the string 
s1
, or at the first null character of the 
s1
, and 
places the result string into 
l
 string.
Example
dim txt as string[16]
    txt_sub as string[5]
    l as string[21]
strcat2(l, txt, txt_sub)  ‘ routine will adjoin strings txt and txt_sub and 
place the result into l
strchr
Prototype
sub function strchr(dim byref s as string, dim ch as byte) as word
Description The function searches the string 
s
 for the first occurrence of the character 
ch
. The null character 
terminating 
s
 is not included in the search.
The function returns the position (index) of the first character 
ch
 found in 
s
; if no matching character 
was found, the function returns 
0xFFFF
.
Example
txt = “mikroElektronika”
res = strchr(txt, “E”)  ‘ routine will locate the character ‘E’ in the ‘txt’ 
string, and return the position of the character
strcmp
Prototype
sub function strcmp(dim byref s1, s2 as string) as integer
Description The function lexicographically compares the contents 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 first pair 
of words that differ in the strings being compared.
Example
txt = “mikroElektronika”
txt_sub = “mikr”
res  =  strcmp(txt,txt_sub)    ‘  compares  strings  ‘txt’  and  ‘txt_sub’  and 
returns returns a difference between the first differing characters, in this 
case 69