Shop OBEX P1 Docs P2 Docs Learn Events
How to call a metode in an object at an upper level ? — Parallax Forums

How to call a metode in an object at an upper level ?

inserviinservi Posts: 113
edited 2007-01-15 16:59 in Propeller 1
Hello,

I try to creat an object for make easy input with the 'TV_Text.spin' object and keyboard with the gestion of a cursor like the input in html.

For that, i created an object caled 'input'. It is 'instancieted' in the 'TV_TEXT' object. The 'input' object need to call some metode in the 'TV_TEXT' object but the 'input' object can not see the TV_TEXT's metodes because it is 'above' to it. Is that possible ?

Thank-You

dro

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
in medio virtus

Post Edited (inservi) : 1/14/2007 8:34:13 AM GMT

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2007-01-13 19:32
    Method access in Spin is strictly hierarchical: objects can "see" below themselves, but not above. However, it's possible to violate the natural order of things by using callbacks. It's highly experimental and definitely not supported, but it might be what you're looking for.

    Before taking this route, though, you might want to reexamine the structure of your code to see if you can do what you want in a way that's supported in Spin.

    -Phil
  • inserviinservi Posts: 113
    edited 2007-01-14 08:54
    Hello Phil,

    I understant that is not a good idea. I'm just disappointing because in this case, i can not make a clean object easy to share. I will simply include the methodes in the 'TV_TEXT' object.

    As i'd like to contribute to the programers comunity, it is not for this time.

    Thank-you for your help.

    (sorry for my bad English, I speak French)


    dro

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    in medio virtus
  • rokickirokicki Posts: 1,000
    edited 2007-01-15 03:00
    I wrote a pair of classes that lets you (for instance) invoke tv_text (and other things) from any
    object, anywhere. I am uploading an example use here.

    The Main class is an example of use. The Singleton class is where you put all the objects you
    want to share globally (like keyboard, or tv_text, or whatnot). The Utility class is where you
    put stubs that invoke the methods you want to access on the objects. Utility is then
    included as a subobject everywhere, but because it has no var space you really only get one
    copy and no additional memory is needed.

    You can also use this to do things like standard out/standard in redirection; so for instance if
    you have tv_text for normal I/O, you can redirect that I/O to my SD writing routines very
    easily. Also, by putting all the I/O stuff in Singleton with links in Utility, you can easily make a
    program that adapts itself to whatever setup people may have (for example, Hydra, or demo
    board; serial LCD I/O vs tv_text vs FullDuplex, etc.)

    It's also a simple example of callbacks (although for general callback use the connect()
    function needs to be moved to Utility so it can be invoked anywhere).

    Enjoy! It rewrites spin opcodes but it does so minimally and pretty simply.
  • inserviinservi Posts: 113
    edited 2007-01-15 16:59
    Than-you rokicki

    I'l try this quickly. It look to be great!

    dro

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    in medio virtus
Sign In or Register to comment.