The book _1001 Things You Wanted to Know about Visual Foxpro_ has an
interesting application which is essentially a standalone command
window for FoxPro. You type in your commands and they are executed,
pretty much like in the regular command window. It seemed to me that
this would be a handy thing to have, but there is a problem that
limits its usefulness. The problem is that all variables created in
the command window are private and not static. So, you can't assign a
value to a variable and then use that variable.

For example, you can assign "Hello" to X, but then you can't use
MessageBox(X) because X isn't around any more.

The question is, is there any way to make all variables default to
global or static?

Regards,
Kevin Clark
Seton Home Study School

Re: Public or static variables question by Stefan

Stefan
Tue Apr 08 14:04:01 CDT 2008


<KevClark64@hotmail.com> wrote in message
news:7545f2ce-baef-48b5-a44e-fceeb50eddf0@t54g2000hsg.googlegroups.com...
> The book _1001 Things You Wanted to Know about Visual Foxpro_ has an
> interesting application which is essentially a standalone command
> window for FoxPro. You type in your commands and they are executed,
> pretty much like in the regular command window. It seemed to me that
> this would be a handy thing to have, but there is a problem that
> limits its usefulness. The problem is that all variables created in
> the command window are private and not static. So, you can't assign a
> value to a variable and then use that variable.
>
> For example, you can assign "Hello" to X, but then you can't use
> MessageBox(X) because X isn't around any more.
>
> The question is, is there any way to make all variables default to
> global or static?

No, I believe you'd need to declare them "Public x,y,z".
I did not test the 1001 Things application you decribed, but
since Vfp's undeclared default variables are visible in subsequent
procedures until the creating stack level has finished, would
something like this work for you:

LOCAL c
TEXT TO c NOSHOW
LOCAL x
x = "Hello"
MESSAGEBOX(x)
ENDTEXT
? EXECSCRIPT(c)

or with a "private" m.x:

x = "Hello"
c = "MESSAGEBOX(x)"
? EXECSCRIPT(c)



hth
-Stefan




--
|\_/| ------ ProLib - programmers liberty -----------------
(.. ) Our MVPs and MCPs make the Fox run....
- / See us at www.prolib.de or www.AFPages.de
-----------------------------------------------------------