Passing temp-tables BY-REFERENCE into class

Posted by alextrs on 11-Feb-2010 20:54

Hello,

I try to pass temp-tables BY-REFERENCE into class:

rToolStripsEditor = NEW Binary.UIElements.ToolStripsEditor (INPUT-OUTPUT TABLE ttblToolStrips     BY-REFERENCE,
                                                                                          INPUT-OUTPUT TABLE ttblObjects_Grp BY-REFERENCE,
                                                                                          INPUT-OUTPUT TABLE ttblObjects        BY-REFERENCE).

everything is ok in constructor and in methods invoked in constructor, all temp-tables' records are available.

But later when in main class I invoke:

WAIT-FOR rToolStripsEditor:Show().

inside of class Binary.UIElements.ToolStripsEditor in trigger Form:Activated and further these temp-tables are empty. If I add:

WAIT-FOR THIS-OBJECT:Show().

into contructor, all records are still available in other methods. Why does it work in this way?

All Replies

Posted by alextrs on 11-Feb-2010 21:11

sorry, when I use

WAIT-FOR THIS-OBJECT:Show().

in the constructor of Binary.UIElements.ToolStripsEditor class, temp-tables are available just in Form:Activated Trigger and then are still not available.

Posted by Admin on 11-Feb-2010 23:30

When you pass a temp-table BY-REFERENCE it will only be availalbe for the duration of that call. So in your case it's the constructor.

Look for defining the temp-table as REFERENCE-ONLY in the class (ToolStripsEditor?) and passing it with the BIND keyword - please read the documentation on the parameter passing syntax for more details. That will create a permanent binding to that one temp-table instance.

(The Dr. will probably tell you it's a bad thing to BIND temp-tables because the ToolStripsEditor now becomes fully dependent on the temp-table owned by somebody else and will have serious issues when that somebody else becomes unavailalbe).

Posted by alextrs on 12-Feb-2010 07:01

(The Dr. will probably tell you it's a bad thing to BIND temp-tables because the ToolStripsEditor now becomes fully dependent on the temp-table owned by somebody else and will have serious issues when that somebody else becomes unavailalbe).

right, that's why I try to use BY-REFERENCE parameter, because I try to avoid being fully dependent (and write one more class/procedure with fetch/save to invoke this one)

BIND works perfectly fine, but I want to use this class (ToolStripsEditor) as dependent and also as not dependent. If it's dependent it should send changes back to the main class, if not - just fetch/save changes itself.

Posted by Thomas Mercer-Hursh on 12-Feb-2010 11:31

As Mike predicts, my inclination would be to wrap the temp-table instead and pass the reference to the object into the constructor.  That way you have one copy and no coupling beyond the interface signature.

This thread is closed