Shop OBEX P1 Docs P2 Docs Learn Events
String parsing issue — Parallax Forums

String parsing issue

Michael kingMichael king Posts: 3
edited 2010-07-13 18:47 in Propeller 1
Letsa say I have a string

String = "ABCDEFG"

How would I strip the A off and use "BCDEFG"?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"I love the smell of solder in the morning"

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-07-13 17:40
    Well, first off, let's correct your syntax:

    s := [b]string[/b]("ABCDEFG")
    
    
    


    Now, s will be the address of an in situ byte array that looks like this: $41 $42 $43 $44 $45 $46 $47 $00. So, if you do:

    t := s + 1
    
    
    


    t will point to the string starting with "B".

    -Phil
  • Michael kingMichael king Posts: 3
    edited 2010-07-13 17:57
    So then this should work but it does not.

    IF buf[noparse][[/noparse]0]=="P"
    ····· text:=buf+1
    ······
    
    
    IF buf[noparse][[/noparse]0]=="P"
          text:=buf+1
    
          comm.str(text)
    

    Buf=PPP1250


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I love the smell of solder in the morning"
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-07-13 18:17
    Try text := @buf + 1. You want an increment of the address, not of the first byte's contents.

    -Phil
  • Michael kingMichael king Posts: 3
    edited 2010-07-13 18:47
    Thank you!!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I love the smell of solder in the morning"
Sign In or Register to comment.