Shop OBEX P1 Docs P2 Docs Learn Events
Set Variable to Dat address — Parallax Forums

Set Variable to Dat address

gianallengianallen Posts: 16
edited 2011-02-02 13:02 in Propeller 1
Hello,

As a test setup for a larger program, I want to iterate through sending byte arrays to a UART from a few Dat locations once every 5 seconds. I assumed, apparently incorrectly, that I could set a variable equal to the name assigned to each of the first values in the DAT array, and that would set the variable equal to that memory address. I figured, again apparently incorrectly, that I could use that variable name just as I would have used the DAT-block "variable" name to access the elements of the array. Instead, it looks as though setting local Var := Dat Block name sets the Var to the value at Dat-block name. Is there a simple way to accomplish what I'm trying to do? Thanks. Here's my code:

EmulateDatMsgs.spin

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2011-02-02 12:53
    You simply do it the wrong way:
    1: CurrentMsg := @Msg1
    2: CurrentMsg := @Msg2
    3: CurrentMsg := @Msg3
    ...
    char := byte[CurrentMsg][idx]
  • gianallengianallen Posts: 16
    edited 2011-02-02 12:55
    Ah... thank you. That makes complete sense. By the way, how do you embed code in-line like I see in so many posts? Thanks again.
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-02-02 12:59
    You put it between [ code ] and [ /code ] tags, but without the space after [ and in front of ]
  • gianallengianallen Posts: 16
    edited 2011-02-02 13:02
    Got it. BTW - my code with the fixes you suggested works perfectly. Thanks again!
Sign In or Register to comment.