Shop OBEX P1 Docs P2 Docs Learn Events
newbee question about variables — Parallax Forums

newbee question about variables

avionikerenavionikeren Posts: 64
edited 2010-01-26 09:40 in Propeller 1
When I define variables this way I got troubles with the variables affecting each other
Variable1    byte[noparse][[/noparse]9]
variable2    byte

But the other way works fine:
Variable2    byte
variable1    byte[noparse][[/noparse]9]

What if I need more variables with many bytes?·

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2010-01-24 17:02
    Nope, if you USE the variables in the right way, they don't affect each other. My guess is that you used

    variable1[noparse][[/noparse]9]

    somewhere. But the index of variable1 is only working inside the assigned RAM from index 0 to 8.
  • avionikerenavionikeren Posts: 64
    edited 2010-01-26 09:35
    Thanks for answer, but I don`t thing I got it, can you please explain a little more simple?

    Do you mean I can not have more than 8 bytes in a variable?
  • BradCBradC Posts: 2,601
    edited 2010-01-26 09:40
    avionikeren said...

    Do you mean I can not have more than 8 bytes in a variable?

    No. If you define a variable as
    byte fred[noparse][[/noparse] 6 ]

    Then you can use fred[noparse][[/noparse] 0 ] through fred[noparse][[/noparse] 5 ].
    If you use fred[noparse][[/noparse] 6 ] it will trample over whatever comes after fred.

    The definition is the number of bytes to reserve, but the usage is 0 based.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life may be "too short", but it's the longest thing we ever do.
Sign In or Register to comment.