Download Datasheet

Transcript
smart BASIC
User Manual
STRSHIFTLEFT
STRSHIFTLEFT shifts the characters of a string to the left by a specified number of characters and
dropping the leftmost characters. It is a useful function to have when managing a stream of
incoming data, as for example, a UART, I2C or SPI and a string variable is used as a cache and
the oldest N characters need to be dropped.
STRSHIFTLEFT (string, numChars)
Function
SUBROUTINE
Exceptions

Local Stack Frame Underflow

Local Stack Frame Overflow
Arguments
string
byRef string AS STRING
The string to be shifted left.
numChrs
byVal numChrs AS INTEGER
The number of characters that the string is shifted to the left.
If numChrs is greater than the length of the string, then the returned string will be
empty.
Note:
string cannot be a string constant, e.g. “the cat”, but must be a string variable and
so if you must use a const string then first save it to a temp string variable and then
pass it to the function
Interactive Command:
NO
DIM s$
S$=”123456789”
Strshiftleft(s$,4)
‘drop leftmost 4 characters
PRINT s$
‘output will be 56789
STRROTLEFT is a core function.
STRCMP
Compares two string variables.
STRCMP(string1, string2)
Function
Returns
A value indicating the comparison result:
0 – if string1 exactly matches string2 (the comparison is case sensitive)
1 – if the ASCII value of string1 is greater than string2
-1 - if the ASCII value of string1 is less than string2
www.lairdtech.com
95
Laird Technologies