Mikroelektronika MIKROE-724 データシート

ページ / 726
674
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
String Library
mikroBasic PRO for dsPIC30/33 and PIC24 includes a library which automatizes string related tasks.
Library Functions
 
- memchr 
 
- memcmp 
 
- memcpy 
 
- memmove 
 
- memset 
 
- strcat 
 
- strcat2 
 
- strchr 
 
- strcmp 
 
- strcpy 
 
- strlen 
 
- strncat 
 
- strncpy 
 
- strspn 
 
- strncmp 
 
- strstr 
 
- strcspn 
 
- strpbrk 
 
- strrchr 
 
- ltrim 
 
- rtrim 
 
- strappendpre 
 
- strappendsuf 
 
- length 
memchr
Prototype
sub function memchr(dim p as ^byte, dim ch as byte, dim n as word) as word
Description The function locates the first occurrence of the byte 
ch
 in the initial 
n
 words of memory area starting 
at the address p. The function returns the offset of this occurrence from the memory address 
p
 or 
0xFFFF
 if 
ch
 was not found.
For the parameter 
p
 you can use either a numerical value (literal/variable/constant) indicating memory 
address or a dereferenced value of an object, for example 
@mystring
 or 
@PORTB
.
Example
txt = “mikroElektronika”
res = memchr(@txt, “e”, 16)  ‘ example locates first occurrence of the letter 
‘e’ in the string ‘txt’ in the first 16 characters of the string