Shop OBEX P1 Docs P2 Docs Learn Events
Access data between Objects — Parallax Forums

Access data between Objects

dondedonde Posts: 51
edited 2009-11-18 18:18 in Propeller 1
Don't have much memory left, so can't rearrange PUB's. What would a function look like to access data from a DAT block of one Object, and pass it to another Object?
Thanks, donde

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-18 17:01
    The general idea of a get / set routine works the same whether the variable is in a DAT block or a VAR block:
    PUB get_varX
       return varX
    
    PUB set_varX(v)
       varX := v
    
    DAT
    varX  long  0
    
  • dondedonde Posts: 51
    edited 2009-11-18 17:18
    And this example will work between 2 different Objects?
    donde
  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-18 17:23
    Yes. get_varX and set_varX are PUB methods and can be called from outside the object.

    Remember that this has nothing to do with whether you're using multiple cogs. If you have two cogs, both attempting to reference the same variable at the same time, you're going to get into trouble whether the variables are all contained and referenced in one object or many objects. These are separate issues.
  • dondedonde Posts: 51
    edited 2009-11-18 18:18
    Thanks, I'll it a try.
    donde
Sign In or Register to comment.