Mikroelektronika MIKROE-724 データシート

ページ / 726
680
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
strcspn
Prototype
sub function strcspn(dim byref s1, s2 as string) as word
Description The function searches the string 
s1
 for any of the characters in the string 
s2
.
The function returns the index of the first character located in 
s1
 that matches any character in 
s2
. If 
the first character in 
s1
 matches a character in 
s2
, a value of 0 is returned. If there are no matching 
characters in 
s1
, the length of the string is returned (not including the terminating null character).
Example
txt = “mikroElektronika”
txt_sub = “mikr”
res = strcspn(txt_sub,txt)
strpbrk
Prototype
sub function strpbrk(dim byref s1, s2 as string) as word
Description The  function  searches 
s1
  for  the  first  occurrence  of  any  character  from  the  string 
s2
.  The  null 
terminator is not included in the search. The function returns an index of the matching character in 
s1
If 
s1
 contains no characters from 
s2
, the function returns 
0xFFFF
.
Example
txt = “mikroElektronika”
txt_sub = “mikr”
res = strpbrk(txt_sub,txt)
strrchr
Prototype
sub function strrchr(dim byref s as string, dim ch as byte) as word
Description The function searches the string 
s
 for the last occurrence of the character 
ch
. The null character 
terminating 
s
 is not included in the search. The function returns an index of the last 
ch
 found in 
s
; if 
no matching character was found, the function returns 
0xFFFF
.
Example
txt = “mikroElektronika”
res  =  strrchr(txt,”k”)    ‘  returns  the  index  of  the  ‘k’  character  of  the 
‘txt’ string
ltrim
Prototype
sub procedure ltrim(dim byref astring as string)
Description The procedure trims the leading spaces of the string.
Example
txt = “  mikroE”
ltrim(txt)  ‘ trims the leading 2 spaces of the ‘txt’ string