Shop OBEX P1 Docs P2 Docs Learn Events
Child and Parent objects using shared drivers - how to get the vars to work cor — Parallax Forums

Child and Parent objects using shared drivers - how to get the vars to work cor

KyeKye Posts: 2,200
edited 2009-04-14 19:15 in Propeller 1
So, I have a parent object that has all my driver objects attached to it through the OBJ statement.

I want to attach a child object to that parent object that uses the same set of drivers. To do that however I need to import the drivers in that childs OBJ section.

However I really don't need sepearte var sections for each object version... Because this prevent the child from actually having working code.

So, how can I get arround this?

I remember looking arround and seeing that if I made the var section in my drivers into a Dat section that the vars would not be replicated again. But I would rather not change my code now.

Is it possible to have the child object import the parent object to gain acess to the drivers which the parent is importing? I could then just have the child call the parent object since the child would be the top object I belive.

Or is there another way to get arround this? Thanks,



▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-04-14 14:23
    You can't do it without changing the code. There's no way to pass methods from parent to child (no way to call a method from a child passed from a parent or a parallel child via the parent).

    The only way around this is to have drivers with no VAR storage and to include these in every object that needs to reference them. Any variables would either be in a DAT area or could be allocated "dynamically" in some otherwise unused area of RAM (like the high end of RAM where some video buffers are sometimes allocated. Only one copy of the code would be stored in hub RAM.
  • KyeKye Posts: 2,200
    edited 2009-04-14 19:15
    Thanks, I thought so.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Nyamekye,
Sign In or Register to comment.