Shop OBEX P1 Docs P2 Docs Learn Events
getting data from another object (without return values) Possible — Parallax Forums

getting data from another object (without return values) Possible

Chicago MikeChicago Mike Posts: 88
edited 2007-11-01 14:19 in Propeller 1
So I'm wondering if anyone knows how to have an external OBJ (Possibly run as a separate COG from the main program) update a variable consistently in the main program (Cog zero). I completely get how to do this if the method being run in another cog is in the same program file, however when its run from a different object this gets me stuck. What I'm trying to do is have a separate entity (Seperate OBJ file) constantly update a few frequently changing variables in the main program. Hence why return values will not work. (Or at least not the conventional way).

Can an external object reference the memory address of a variable in the main program? (@Main_variable). If so how to do declare it in the object so it knows where it is?

Thanks.

Comments

  • RaymanRayman Posts: 14,219
    edited 2007-11-01 13:14
    I think you just pass the address to the object and then use, e.g., "LONGMOVE" to update the hub RAM address.
  • Ken PetersonKen Peterson Posts: 806
    edited 2007-11-01 14:19
    Provide a getter method in your object to get the address of the variable in which you pass your parameter. Your top object then calls the method to get the address of the variable. The variable would be defined in your included object, not the top object.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    The more I know, the more I know I don't know.· Is this what they call Wisdom?
Sign In or Register to comment.