Is it possible to undefine a shared variable?

ezequiel

Member
Hi everyone, I'm new in this forum.

I'm trying to undefine a variable previously defined like "DEFINE NEW SHARED VARIABLE".

Is it possible?


Thanks
 
Hi ezequiel,

No, this is not possible. The only way to no longer have the shared variable available is to run a procedure that does not declare the shared variable, or to return to a procedure higher in the procedure stack where the variable was not yet declared. In those procedure you will then not have the variable available.

Anyway, I do not know what it is you want to be doing and I do make it a rule myself not ever to declare anything as shared. Especially in "event driven" programming these guys can be very tricky customers to deal with, very hard to trace and can potentially seriously mess up your logic. I personally see shared variables more as a leftover from times gone by and only there to keep any old (pre version 7) programs running.

Maybe if you can tell us a little more about what it is you are trying to do, someone may have a good suggestion on how to accomplish that without shared variables.

Paul
 
Personally, I find shared variables quite useful, but there you go. Everyone has their own ways of coding.

A shared variable is, as far as I am aware, only shared according to how it is defined.

So, if p1.p has a new shared variable and calls p2.p that has the shared variable defined and calls p3.p then you can access the shared variable in p3.p.

If you don't define the shared variable in p2.p and run p3.p from p2.p then I don't think it will like the shared variable definition.

If you use "define new global shared variable" then it can handle skips so p3.p would work just fine.

Also, if you redefine the variable in another program, then that kills off the shared variable, but a global shared variable will still be available in other programs.

So, if you have:
p1.p: define new shared variable myshared as char no-undo.
p2.p: define shared variable myshared as char no-undo.
p3.p: define variable myshared as char no-undo.
and p1.p calls p2.p which calls p3.p then p3.p will not share the variable.

Also, if you use
p3.p: define new shared variable myshared as char no-undo.
and p1.p calls p2.p which calls p3.p then p3.p will start the share again and anything further down the line will share the variable up to p3.p. This can be confusing, especially if the variable is defined as new several times.

So, if you have a variable that has been shared and you don't want it shared past the current program but want to use the same variable in your program, just redfine it without the shared part. But be careful, shared variables are normally shared for a reason.

How's that? Clear as mud?
 
And then someone changes somewhere in the stack of programs the value of a shared variable...
This can be very awkward to trace down. It's hard to keep track of the context of shared variables so maintenance in one program can easily lead to problems in another program.
I myself like to keep things scoped to the procedure I'm in.

Casper.
 
Thanks to all of you; now I have some thing to think about, hahaha.

The problem just happens in appbuilder; the only solution is quitting of it and re-entering, using a new startup procedure.

Thanks again


Ezequiel
 
The problem just happens in appbuilder;
Aha!! So you may have a very different problem. What exactly IS the problem in relation to shared variables and the AppBuilder that you are experiencing and attempting to resolve? :confused: If you explain this in some more detail, then perhaps people here can be of more help to you :)
 
Back
Top