Mikroelektronika MIKROE-724 データシート

ページ / 726
678
mikoBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
strcpy
Prototype
sub procedure strcpy(dim byref s1, s2 as string)
Description The function copies the value of the string 
s2
 to the string 
s1
 and appends a null character to the end 
of 
s1
.
Example
txt = “mikroElektronika”
txt_sub = “mikr”
strcpy(txt,txt_sub)  ‘ copies string ‘txt_sub’ to ‘txt’
strlen
Prototype
sub function strlen(dim byref s as string) as word
Description The function returns the length, in words, of the string 
s
. The length does not include the null terminating 
character.
Example
txt = “mikroElektronika”
res = strlen(txt)  ‘ calculates the length of the ‘txt’ string, result = 16
strncat
Prototype
sub procedure strncat(dim byref s1, s2 as string, dim size as word)
Description The function appends at most 
size
 characters from the string 
s2
 to the string 
s1
 and terminates 
s1
 
with a null character. If 
s2
 is shorter than the 
size
 characters, 
s2
 is copied up to and including the 
null terminating character.
Example
txt = “mikroElektronika”
txt_sub = “mikr”
txt[5] = 0
strncat(txt,txt_sub,4)  ‘ routine appends first 4 characters from the string 
‘txt_sub’ at the place of first null character in the ‘txt’ string
strncpy
Prototype
sub procedure strncpy(dim byref s1, s2 as string, dim size as 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 first 4 characters form the string ‘txt_sub’ 
to ‘txt’