Shop OBEX P1 Docs P2 Docs Learn Events
Strings manipulation — Parallax Forums

Strings manipulation

El PaisaEl Paisa Posts: 375
edited 2006-10-02 17:33 in Propeller 1
I need help from someone.
I think it is something very simple but I have my head hitting the walls.

I need to convert keyboard characters into strings and concatenate them.
For instance, if I type 1,2,3,4,5 and want to have a string "12345"

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-02 07:47
    OBJ key : "keyboard"
    VAR byte buffer[noparse][[/noparse]32]
    PUB mainProgram | stopChar
    '' Example of call: stopChar := getNumber(@buffer,32)
    PUB getNumber(ptr, size) | c
    '' This takes a series of digits from the keyboard
    '' and returns the first non-digit character received.
    '' The characters are returned as a zero-terminated
    '' string whose address is supplied in ptr and whose
    '' maximum size is supplied in size.
      repeat (c := key.getKey)
        case c
          "0".."9":
            if size > 1
              byte[noparse][[/noparse]ptr++] := c
              size--
          other:
            byte[noparse][[/noparse]ptr] := 0
            return c
    
    
  • El PaisaEl Paisa Posts: 375
    edited 2006-10-02 17:33
    Thanks Mike.

    I am going to try it.
Sign In or Register to comment.