Shop OBEX P1 Docs P2 Docs Learn Events
Symbol Address of an Array — Parallax Forums

Symbol Address of an Array

Michael @ AfineolMichael @ Afineol Posts: 33
edited 2010-03-22 03:30 in Propeller 1
VAR
  BYTE arrSet[noparse][[/noparse]25]
  WORD RecordCounter         'This will track where to write the next record
 
 
PUB Init
  Object(@RecordCounter, @arrSet)
'  ..Additional Code
 
  Object2(@RecordCounter, @arrSet)
'  ..Additional Code

 
   
PUB Object(vPTR_Record, aSet) | Offset, T 
  Repeat T From 1 to 3
    Offset := WORD[noparse][[/noparse]vPTR_Record]
    BYTE[noparse][[/noparse]aSet + Offset] := 0
    WORD[noparse][[/noparse]vPTR_Record]++  
 

PUB Object2(vPTR_Record, aSet) | T 
  Repeat T From 1 to 3
   BYTE[noparse][[/noparse]aSet[noparse][[/noparse]WORD[noparse][[/noparse]vPTR_Record]] := 1
   WORD[noparse][[/noparse]vPTR_Record]++  

In SPIN I want to pass the Address of an Array and·the·Address of the Offset of the starting address of the Array into an Object. In the code above I have 2 examples. Which one will let met manipulate the data of the Array passed into the Object so when the Object is complete the data stays modified and the RecordCounter is incremented to the next available record.

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2010-03-22 03:30
    Provided the missing closing bracket in

    BYTE[noparse][[/noparse]aSet[noparse][[/noparse]WORD[noparse][[/noparse]vPTR_Record]] := 1
    


    is right after aSet, both access methods are equivalent (the second is slightly shorter). If you put it at the end you're in deep water [noparse]:)[/noparse]
Sign In or Register to comment.