Shop OBEX P1 Docs P2 Docs Learn Events
Constant array of string — Parallax Forums

Constant array of string

Bill DrummondBill Drummond Posts: 54
edited 2009-03-17 00:53 in Propeller 1
With Pascal I can do:
const
·commands : array[noparse][[/noparse]0..3] of string[noparse][[/noparse]3] = ('dir','del','cpy','typ' );

how is it done with spin?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-03-17 00:34
    You'd use a DAT block like:
    DAT
       commands   byte  "dir",0, "del",0, "cpy",0, "typ",0
    


    To access these, you'd use a subscript that's a multiple of 4 like @command[noparse][[/noparse] 0 ] or @command[noparse][[/noparse] 12 ]. These would give you the address of the string(s). If you want to access individual characters, you could just use command[noparse][[/noparse] x ] where x is between 0 and 15.
  • Bill DrummondBill Drummond Posts: 54
    edited 2009-03-17 00:53
    Thanks mike, that makes sense and it works too.
Sign In or Register to comment.