Shop OBEX P1 Docs P2 Docs Learn Events
Access Bytes of Long Array — Parallax Forums

Access Bytes of Long Array

JCeeJCee Posts: 36
edited 2009-12-01 09:57 in Propeller 1
I am trying declare bytes of long arrays and I cant get it to work

Var
·Long Point[noparse][[/noparse]10]

·Point[noparse][[/noparse]0].byte[noparse][[/noparse]0]:= 10
·Point[noparse][[/noparse]0].byte[noparse][[/noparse]1]:= 20
·Point[noparse][[/noparse]0].byte[noparse][[/noparse]2]:= 30

·Point[noparse][[/noparse]1].byte[noparse][[/noparse]0]:= 10
·Point[noparse][[/noparse]1].byte[noparse][[/noparse]1]:= 20
·Point[noparse][[/noparse]1].byte[noparse][[/noparse]2]:= 30

I would like to be able to loop thru an array of points and set values of specific bytes.

Do·I have a syntax problem or is there a better way to do it. ·

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-11-30 21:30
    What you're doing should work. What behavior do you observe that's unexpected?

    -Phil
  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-30 21:33
    The problem is that you can't use subscripts on both parts of the variable descriptor. You can't say "Point[noparse][[/noparse]x].byte[noparse][[/noparse]y]". What you can do is "Point.byte[noparse][[/noparse]x*4+y]".
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-11-30 22:02
    My bad! Mike is right. I was so lulled by the innate naturalness of Point[noparse][[/noparse]*1].byte[noparse][[/noparse]*2] := 30 (odd that it's not allowed) that I didn't question it. You can also do:

    [b]byte[/b][noparse][[/noparse]*@Point[noparse][[/noparse]*1]][noparse][[/noparse]*2] := 30
    
    
    


    if you don't want to do the address calculation explicitly.

    -Phil
  • JCeeJCee Posts: 36
    edited 2009-12-01 03:21
    Thanks
    the loops run as expected
  • Clock LoopClock Loop Posts: 2,069
    edited 2009-12-01 09:57
    If you use DAT, you can just do this...


    
    DAT
    
    
     
     Point0      BYTE     10, 20, 30
    
     Point1      BYTE     10, 20, 30
    
    
    



    Propeller manual page 99.
Sign In or Register to comment.