Shop OBEX P1 Docs P2 Docs Learn Events
Referencing CON and DAT information from other Objects — Parallax Forums

Referencing CON and DAT information from other Objects

Dave HeinDave Hein Posts: 6,347
edited 2010-03-22 20:31 in Propeller 1
I would like to be able to reference constants and data tables that are defined in one object from another one.· As a simple example, I would want to define NULL in one object, and use it in another.· A more complex example would be to define the fixed offsets of varaibles within a data structure and allow another object to access these constants.· Is there anyway to do that in Spin?

At one point I had throught that variables defined in DAT sections could be shared by other objects.· However, there this doesn't seem to work.· Is there anyway to do this?

The only way I can see to resolve either of these issues is to provide methods that return the value of a constant and pointers to areas of memory in the DAT section.

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2010-03-22 20:22
    Constants are accessible by the program that includes the object in it's OBJ-section. Say your object is named OBJ1, then you can access the constants by OBJ1#NULL.

    No other elements except the pub-functions are visible from outside of an object, so ... yes ... you have to define functions to retrieve the addresses of DAT or VAR variables.
  • Dave HeinDave Hein Posts: 6,347
    edited 2010-03-22 20:31
    MagIO2,

    Thanks, that's very helpful.

    Dave
Sign In or Register to comment.