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?
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.
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).
(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.
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.