I made this for parsing commands received from a serial connection .
its pretty simple to use ,quick and efficient
usage
needs a pic18 or pic16f1xxx enhanced core
there is an ASSEMBLER DEFINE TO REPLACE TOKEN WITH NULL "C" STYLE IN INPUT if required
example
some data to play with
arraywrite head,["i 123,p4,d 5678,t43,s-4",13,10,"j 777",13,10]
first call zero index and set token
strtok head,0,","
result
STRTOK_LEN=6
STRTOK_INX=6
next call
strtok head {same token}
STRTOK_LEN=3
STRTOK_INX=9
next call
strtok head {same token}
STRTOK_LEN=7
STRTOK_INX=16
seek a different token
strtok head, "s"
STRTOK_LEN=5
STRTOK_INX=21
when chr(10) or chr(0) is encountered the sequence will terminate
its pretty simple to use ,quick and efficient
usage
needs a pic18 or pic16f1xxx enhanced core
there is an ASSEMBLER DEFINE TO REPLACE TOKEN WITH NULL "C" STYLE IN INPUT if required
example
some data to play with
arraywrite head,["i 123,p4,d 5678,t43,s-4",13,10,"j 777",13,10]
first call zero index and set token
strtok head,0,","
result
STRTOK_LEN=6
STRTOK_INX=6
next call
strtok head {same token}
STRTOK_LEN=3
STRTOK_INX=9
next call
strtok head {same token}
STRTOK_LEN=7
STRTOK_INX=16
seek a different token
strtok head, "s"
STRTOK_LEN=5
STRTOK_INX=21
when chr(10) or chr(0) is encountered the sequence will terminate
Comment