Shop OBEX P1 Docs P2 Docs Learn Events
getting the first so many chars of a string? — Parallax Forums

getting the first so many chars of a string?

adriadri Posts: 34
edited 2009-08-16 13:01 in Propeller 1
hi

I want to grab the first 'x' number of chars from a string to do a string compare later.

If anyone can help it'd be appreciated..

Cheers

Adri

Comments

  • localrogerlocalroger Posts: 3,452
    edited 2009-08-16 13:01
    That one's easy. Your string is really a byte array, just set the byte after the last one you want to zero.

    var
    byte mystring[noparse][[/noparse] 32 ]

    pub
    bytemove(@mystring,string("Roger Williams"),15)
    mystring[noparse][[/noparse] 5 ] := 0
    text.out(@mystring) 'prints "Roger"

    Post Edited (localroger) : 8/16/2009 1:09:45 PM GMT

Sign In or Register to comment.