strcomp
Tumbler
Posts: 323
Hello
I have some troubles with a sub.
This one works:
I have some troubles with a sub.
This one works:
PUB waitOK | succes succes := false repeat until Gsm.rxcheck < 0 if gsm.Rx == 13 if gsm.Rx == 10 if gsm.Rx == 79 if gsm.Rx == 75 if gsm.Rx == 13 if gsm.Rx == 10 succes := true gsm.rxflush return succesAnd this one doesn't. was wondering why.
PUB waitOK | succes succes:= false repeat gsm.RXstr(@Buff) while Buff[0]== -1 if strcomp(@Buff,@ok) succes := true gsm.rxflush return succes Dat ok Byte 13,10,79,75,13,10,0
Comments
I wrote this method for checking the presence of one string inside another -- can even specify the number of characters to scan. I use this when I am parsing commands out of longer strings.
As you're providing the number of characters/bytes to compare, it will work with any two arrays of bytes.