Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why define constants
Message
From
25/10/2006 13:14:15
 
 
To
25/10/2006 12:50:09
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01164235
Message ID:
01164463
Views:
10
>>>>Sorry for you Jim, but you are 100% wrong. <g>
>>>
>>>OK. Just tell me how you know that.
>>>
>>>Surely you're not relying on a DISPLAY MEMORY command output as the "proof"?
>>
>>Jim u can read the VFP help FOR the #DEFINE
>>This was taken from the beguinning.
>>
>>Creates and releases compile-time constants.
>>
>>You can use the #DEFINE and #UNDEF preprocessor directives to create compile-time constants in programs. By creating constants with #DEFINE instead of using variables, you can reduce memory consumption, increase performance, and simplify programs.
>
>Very good, Alexandre.
>But it is possible that "reduce memory consumption" means 'reduce the impact on MVCOUNT'.
>It could also be that "increase performance" refers to something totally different than the 'constant' being included in-line *IN* the instruction. For example, maybe it is the case that memvars have to go through the 'is it a field name or a memvar' check before being used whereas 'constants' are in their own separate 'pool' where that is not an issue. In which case it's *possible* that using m. makes memvar usage virtually as fast.
>As for simplifying programs, that's debateable. I've seen Sergey ask (and be correct) a few times 'are you sure you don't have a constant defined with the same name'. And to me hidden things are intrinsically *not* "simplification".
>
>In other words, the statements in Help don't do a whole lot to clarify the situation.
>
>But in the end this is another of those VFP capabilities that comes down to personal taste.
>
>cheers
>>
>>To create a constant with #DEFINE, specify the constant's name with ConstantName and its value with eExpression. When the program is compiled, text substitution is performed and the constant value expression is substituted for the constant name wherever it appears in the program. You can stop the substitution for the constant by issuing #UNDEF.
>>


Jim,

If you have the "Hackers Guide to Visual FoxPro 7" look up #DEFINE. It states pretty clearly the constants in the program code get replaced by the defined value before the code is actually "compiled".

Regards,
Jim
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform