Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Different between private and local
Message
From
01/11/2000 05:19:11
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
01/11/2000 02:23:05
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00436575
Message ID:
00436603
Views:
19
>Hello all,
> I have a interest to know what is the different between 'PRIVATE' AND 'LOCAL' variable. I use VFP6, I always use LOCAL in my program and it seems working fine. But I like to know when I can use PRIVATE will be better?
> I have read the VFP online help many time about these two keyword, but I am too stupid to know the different.
> Thanks for all.
>-Jasper^_^

Jasper,
Actually don't bother and continue to use local. Historically local was introduced to Foxpro after private. There are slight differences like one creates vars while other doesn't, local narrowes the scope to procedure while private ones could be seen by lower level procedures etc. but practically local would work nicely IMHO. Here is a very simple sample :
m.Test1 = 1
? 'Before func calls', m.test1
=Func1()
? 'After func calls', m.test1

function func1
private all
on error wait window 'Var not defined yet'
? 'Func1 before assignment', m.test1 && Error
on error
m.test1 = 5
? 'Func1', m.test1
=func2()
? 'Func1 after Func2 call', m.test1

function func2
local m.test1
? 'Func2', m.test1 && No error-var initialized to .f.
=func3()
? 'Func2 after Func3 call', m.test1

function func3
? 'Func3 before value change', m.test1 && m.Test1 from func1
m.Test1 = m.test1^2
? 'Func3 after value change', m.test1
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform