Re: Intermittent Error 12 - Variable Not Found
- From: Gene Wirchenko <genew@xxxxxxxx>
- Date: Tue, 27 Mar 2007 20:11:13 -0700
"Fred Taylor" <ftaylor@xxxxxxxx!REMOVE> wrote:
As Gene has pointed out to you, your assumptions are incorrect.
Variables declared PUBLIC are visible to all code, above and below the
routine in which they are defined. They do not go "out of scope" unless
they are specifically released or a CLEAR ALL is issued.
Variable declared PRIVATE work more like what you described. They are
visible to all routines called from the defining code, but are automatically
released when the defining code exits.
Actually, variables are not declared private. A private
statement hides variables, so that any use of the same name refers to
a different variable. A private variable's scope is that of the
routine in which the variable is first assigned a value unless
overridden by another declaration further down the call tree. This
might not be the same routine that the private statement is in, as in:
private memvar
do assignval
? somevar
procedure assignval
somevar=5
return
endproc
will throw an error, because somevar is released at the end of the
procedure in which it is first assigned a value. If you add
somevar=0
just after the declaration, the output will be 5.
Variables declared as LOCAL are only visible in the defining routine. They
are not visible in any code called by the defining routine.
And, they remain in existence until the defined routine
terminates.
I'd recommend reading the sections of help on the above topics for more
details.
Yes. It was a bit of a surprise when I got caught by how private
variables really work.
Sincerely,
Gene Wirchenko
Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.
.
- Follow-Ups:
- Re: Intermittent Error 12 - Variable Not Found
- From: Peter Huish
- Re: Intermittent Error 12 - Variable Not Found
- References:
- Intermittent Error 12 - Variable Not Found
- From: Peter Huish
- Re: Intermittent Error 12 - Variable Not Found
- From: Stefan Wuebbe
- Re: Intermittent Error 12 - Variable Not Found
- From: Peter Huish
- Re: Intermittent Error 12 - Variable Not Found
- From: Fred Taylor
- Intermittent Error 12 - Variable Not Found
- Prev by Date: Re: missing subreport?
- Next by Date: Re: Sydney Foxpro user group meeting tonight
- Previous by thread: Re: Intermittent Error 12 - Variable Not Found
- Next by thread: Re: Intermittent Error 12 - Variable Not Found
- Index(es):
Relevant Pages
|
Loading