Main Board > Nomads

Creating a new instance of an object especially for a Query

(1/2) > >>

Arno de Greef:
Hello,

We have created an object to read some information from our database. We would like to show this information in a column of a query. We want to create a new instance of the object when starting the query and drop the object when closing the query.

To do this, we're looking into the Initialization and Closing procedures on the interface tab of the query interface. During the initialization procedure we need create the object and make the objects CTL available to both a formula in the query itself and the closing procedure. To that end we tried normal (non global) variabeles. This seems to work file with classic queries, however in query+ queries the CTL can be used in the formula but does not arrive in the closing procedure. Naturally we could use a global variable, but we worry about the scope of these variables. Chances are we will use multiple (same) queries at the same time causing the risk of globals overwriting each other.

Is there anybody out there with experience in this matter who is willing to share  :) ?

Thanks,
Arno de Greef

Stéphane Devouard:
Hi Arno

PxPlus has an interesting concept of LOCAL globals

If you declare
LOCAL %INFO$ in a program

Then %INFO$ will be global in the current stack level and "above"
If there is another similar declaration in a higher stack level, then the current %INFO$ value will be preserved, the new value will replace it, and when dropping to a lower stack level, the preserved value will be restored

Hope this helps

Arno de Greef:
Hi Stéphane,

This sounds interesting. Will have a look !

Thanks,
Arno de Greef

Arno de Greef:
Hi Stéphane,

In queries I use the Initialization and Closing procedures, which are calls. To get any result from the query, I have to leave that call. This means dropping to a lower stack and loosing the local global I created in the call.

I think local globals are great, but I'm affraid they can't help in this situation.

Thank you for your suggestion.

Arno de Greef

PxPlus:
Actually why not just pass a variable to contain the object handle into the initialization call, set it during initialization, then during the finalization pass the same variable and drop the object.  The variable you pass in should remain localized to the current Query session.

Navigation

[0] Message Index

[#] Next page

Go to full version