SERIN string match?
astropaul
Posts: 17
Hi,
I am processing SERIN data, and want to perform a different task depending on the incoming command.
Say my command is "get temp" or "put led,1"
So the first 3 chars could be get or put. How can I match on the first three chars?
IF buffer(3) = "get"
doesn't work. It only wants to process the first byte of the array.
How do I compare multi byte strings?
Thanks,
Paul
I am processing SERIN data, and want to perform a different task depending on the incoming command.
Say my command is "get temp" or "put led,1"
So the first 3 chars could be get or put. How can I match on the first three chars?
IF buffer(3) = "get"
doesn't work. It only wants to process the first byte of the array.
How do I compare multi byte strings?
Thanks,
Paul
Comments
PBASIC has very little in the way of string handling. Why not just limit the command to one character ("G" or "P") that simplifies the process immensely.
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->
[noparse][[/noparse]code]GT CON "G'" * 256 + "T" ' command "%GT", "%" is command tag
PL CON "P" * 256 + "L" ' "%PL"
command VAR word
cmd0 VAR command.byte0 ' alias byte 0
parameter VAR word
DEBUGIN WAIT("%"),STR cmd0\4 ' reads in both command and parameter words
LOOKDOWN command,[noparse][[/noparse]GT,L1],cmd0 ' convert to index
BRANCH cmd0,...... ' branch on index, parameter intact[noparse][[/noparse]/tag]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com