Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Private vars
Message
From
01/06/2001 09:50:35
 
 
To
01/06/2001 09:38:25
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00513736
Message ID:
00513744
Views:
17
This message has been marked as a message which has helped to the initial question of the thread.
PRIVATE variables are visible in the entity where it was defined AND any entity called by that entity. LOCAL variables are scoped to the entity where it was defined. GLOBAL variables are visible everywhere in your APP.

Therefore:
PROCEDURE Main
PRIVATE x
LOCAL y, z

x = 1
y = 2
z=MyFunction()
ENDPROC

FUNCTION MyFunction

?x && This will print 1 since x is visible here
?y && This will cause an error since y is declared above is not visible here

RETURN 1
>reading a recent post, I read ( then proved ) that if you declear a private var in you main program it will have golbal scope.
>
>WHY!!!?!?!?!
>
>unless I'm mistaken, in most ( if not all ) other programming languages when you declair a private var it is scoped to that file, method, function, etc. I should be able to declair the Var isSomeThing as private anywhere in the program, and anywhere else ( other than that function, etc. ) isSomeThing should not exist, irregardless of how it came to that piece of code ( even if it is in the main.prg file ).
>
>I don't understand why the deviation on something so primitive.
>
>- jer
Thanks,
Dan Jurden
djurden@outlook.com
Previous
Reply
Map
View

Click here to load this message in the networking platform