Shop OBEX P1 Docs P2 Docs Learn Events
question about Parent & child using same object — Parallax Forums

question about Parent & child using same object

ericballericball Posts: 774
edited 2009-07-25 00:09 in Propeller 1
I'd like to avoid problems, but I'm not sure if there's an easy way.

I have three objects - Foo, Bar and Baz.· Foo is the parent, and has Bar as an OBJ.· Both Foo and Bar include a Baz as an OBJ.· Baz has a cog routine (like fsrw or Parallax Serial Terminal) which gets started once and is then controlled via various SPIN routines.

My understanding is by default there will be two sets of VARs for Baz - and two instances of the cog driver.· Changing the VARs in Baz to DATs makes it static - working around the problem, but is there any other way?


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Composite NTSC sprite driver: Forum
NTSC & PAL driver templates: ObEx Forum
OnePinTVText driver: ObEx Forum

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-07-25 00:09
    "is there any other way?" ... not really.

    If you only call Baz's start method once from Foo, you should have only one instance of the cog driver. You'll have to have the variables in Baz either in the DAT section or perhaps dynamically allocated from somewhere else in RAM (by you), like the end of memory.

    Every time you have an OBJ statement referencing Baz, you'll get a separate instance of Baz with its own VAR section. Even if you don't use a VAR section, there'll still be a method table for each instance (an internal table). This is relatively small and normally isn't an issue.
Sign In or Register to comment.