Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
I wish this was in VFP and not VB.....
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00519713
Message ID:
00520753
Views:
35
>>>>>#DEFINE's are string translations that take place at compile-time not run-time. That is, when PRG's etc. are converted into FXP's or EXE's etc.
>>>>
>>>>Houston,
>>>>
>>>>This isn't correct if the #DEFINE contains a function such as your INLIST() example. These are evaluated at run-time.
>>>
>>>George,
>>>I just entered the following code into VFP6 SP3 running on NT4 SP6.
#DEFINE Sunday 1
>>>#DEFINE Saturday 7
>>>#DEFINE AWeekend   INLIST( iDayOfWeek, Saturday, Sunday )
>>>
>>>CLEAR
>>>dCurrent = DATE()
>>>iDayOfWeek = DOW( dCurrent )
>>>IF (AWeekend) THEN
>>>   ? "Yes it's a weekend."
>>>ELSE
>>>   ? "Not a weekend"
>>>ENDIF
In my Edit, Preferences, I have 'Compile when saved' checked. After compiling the prg and running it for today (Monday), I get "Not a weekend", and then I changed the date to Sunday using my system clock and immediately ran the prg again (without any modifications and/or recompiling) - as expected the message changed to "Yes it's a weekend."
>>>
>>>If the INLIST() is 'evaluated' at compile-time, why does the message change?
>>
>>Houston,
>>
>>This is what you said,
>>
>>"#DEFINE's are string translations that take place at compile-time not run-time. That is, when PRG's etc. are converted into FXP's or EXE's etc."
>>
>>What I am saying is that if the #DEFINE contains a function call such as INLIST() this statement is not correct. These are dynamic and evaluate differently at run-time.
>
>Hi George,
>I'd appreciate (and I'm sure a whole bunch of lurkers would also appreciate) a piece of code that demonstrates the 'evaluate differently at run-time'.


Sure, try this:
#DEFINE DEFAULT_DIR SYS(5) + SYS(2003)
in a header file. Compile the application and drop it into a directory other than the compiled directory. It will display the current default directory, not the one that the application was compiled in.

This discussion has occurred a couple of times in the past, BTW.
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform