Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Memory Variable and Local Variable....
Message
From
05/10/1998 06:44:11
 
 
To
05/10/1998 01:23:31
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00143781
Message ID:
00143800
Views:
19
>we can 'Use' a variable with/without declaration.
>
>e.g. we can:
>
>abc = dtos(date())
>Messagebox(abc)
>
>or
>
>Local abc
>abc = dtos(date())
>Messagebox(abc)
>
>or
>
>Local abc
>abc = dtos(date())
>Messagebox(m.abc)
>
>

>
>What is the different between abc and m.abc?!

Nothing, as long as you don't have a field with the name 'abc'. The 'm.' qualifier instructs VFP to use the memory variable in prference to a field with the same name in the currently selected work area; VFP's default behavior is to resolve to the field name rather than the memory variable if both a field in the currently selected table and a variable have the same name.

>What is the different on Declare Local or Not?!

Scoping of the variable. Variables declared as LOCAL are not visible outside of the procedure, function or method that they are declared in (unless passed by reference, in which case the PARAMETER or LPARAMETER statement provides access); undeclared variable references, or variables declared as PRIVATE, are visible to procedures and functions called from the procedure in which the variable is created.

>
>

>
>For my observe, if using recusion without Local declaration,
>problem will come out!
>
>setAllFonts()
>Lparameters SetObject, nFontsize
>
>For iX = 1 to SetObject.Controlcount
> if Pemstatus(SetObject.controls[iX], "Fontsize", 5)
> SetObject.controls[iX].fontsize = nFontsize
> endif
>
> if Pemstatus(SetObject.controls[iX], "Controlcount", 5)
> SetAllFonts(Object.controls[iX], nfontsize)
> endif
>EndFor
>
>The problem comes in inner recusion as the iX variable will reset to 1 again but afterwards, when back to outer loop.
>the iX variable may smaller than previous value!
>
>This is because the variable still not out of scope!
>but there will work fine if there is line:
>
>Local iX && in the prg file! ^_^;
>
>

>
>Another thing on Macros,
>
>abc = Dtos(Date())
>what are different on:
>
>abc, (abc), &abc, (&abc), and also "&abc"
abc is the variable itself
(abc) in a name reference resolves to the name contained in the variable abc
&abc macro-expands the variable abc
(&abc) resolves the name formed by the string resulting from macro-expanding abc
"&abc" quote-encapsultes the macro expansion of abc
>
>which should be used on value!?

MyProperty.value = abc
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Previous
Reply
Map
View

Click here to load this message in the networking platform