Announcement

Collapse
No announcement yet.

strtok usercmd

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • strtok usercmd

    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
    Attached Files

  • #2
    Thanks for posting Richard. I am sure it will be very handy.

    Ioannis

    Comment

    Working...
    X