Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Defining a global property for an application
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00357663
Message ID:
00357812
Views:
18
Hi Ed,

You're trying to explain me things, which I already knew or discovered by experience.

Let me describe, that exactly I did and tell me, what's wrong:
In the main program I do:
private pcTable
pcTable='' && This makes this variable really created
do form form1
read events

* pcTable exists and visible in all events and methods of Form1

do form form2

pcTable is visible in DE.BeforeOpenTables and Form.Init (haven't tested in Load, but assume, it would be visible here too). Then it becomes invisible in other methods (in Add method or in Close method)...

When I discovered this behavior (it was just recently) I was a little suprised, so I made a test, showed above.

Now, how can you explain this difference (with vs. without read events)?

Thanks in advance.

>> I made the same assumption, but it's not a truly right. I declare a private variable in a main program pcTable and assign pcTable='' (This is important to assign a value, before using a variable). Then I create a form and test, if this variable is still visible. I found, that if I issue Read Events after
>>do form MyForm, this variable is still visible in all methods and events, otherwise this variable is visible only for Init and then it becomes out of scope. You can test it.
>
>Read the docs on PRIVATE - it hides prior declarations but does not explicitly create the variable. If this were not the case, please explain how PRIVATE could support wildcarding:
>
>PRIVATE ALL LIKE p*
>
>would have to create an essentially infinite number of variables (at a minimum, 27*(37^128) seems to ring a bell, but clearly a lot more than the maximum value of MVCOUNT.
>
>Look at the difference in how the LOCAL and PRIVATE declarations are defined in the VFP docs - PRIVATE states that it hides previously-instanced variables, while LOCAL explicitly creates variables.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform