Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
I wish this was in VFP and not VB.....
Message
 
 
To
18/06/2001 15:38:44
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00519713
Message ID:
00520746
Views:
44
>>>>>>>#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?
>>>>
>>>>Hi Houston,
>>>>
>>>>Look, that George wrote to you:
>>>>>>This isn't correct if the #DEFINE contains a function such as your INLIST() example. These are evaluated at run-time.
>>>>
>>>>With whom do you argue? :)
>>>
>>>Hi Nadya,
>>>
>>>With George! Since it was he that stated my example was not correct. Some additional hints: my reply was to George and I started the message with 'George'.
>>>
>>>I really hope I have not woke up to a 'Ground Hog Day' experience :-)
>>
>>Ok, let's try one more time (BTW, lurkers like me benefit from this discussion):
>>
>>You:
>>#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.
>>
>>George:
>>This isn't correct if the #DEFINE contains a function such as your INLIST() example. These are evaluated at run-time.
>>
>>Now it's clear, what part of sentence George referred as incorrect statement. In your sample you just confirmed it again. :))
>>
>>Simple logic thing, nothing more. :)
>
>PMFJI but........
>
>I've just run Houston's code and it worked just fine for me. I think the confusion is that
>
>
#DEFINE AWeekend   INLIST( iDayOfWeek, Saturday, Sunday )
>
>isn't doing any calculation at this point. At compilation time
>
>
IF (AWeekend) THEN
>
>will be compiled to
>
>
IF INLIST( iDayOfWeek, Saturday, Sunday ) THEN
>
>and all is fine

Do you have ReFox or any other tool to de-compile this code? But I think, you're right.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform