Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Constant
Message
From
02/09/2006 08:06:10
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
02/09/2006 07:41:44
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01150492
Message ID:
01150495
Views:
15
Yes, that is the idea of #DEFINE constants - that they are evaluated at compile time. They are replaced in the program before the main phase of the compilation. For instance, if you use:
#DEFINE MAX_USERS 100
Then the compiled file will not have any variable MAX_USERS; instead, it will have the value 100 everywhere you had used MAX_USERS.

For the need you describe, you should use a variable, not a #DEFINE.

>Hi,
>Is constant evaluated only during compile time?
>
>At first, I hardcoded my application folder as constant.
>
>
>#DEFINE   APPFOLDER      "C:\myproject\"
>#DEFINE   MYPRGFOLDER    APPFOLDER + "PRGS"
>
>?MYPRGFOLDER     && Show C:\myproject\PRGS
>
>
>Then, I changed my code to allow user to specify app folder during runtime. So I changed code as below.
>
>
>**#DEFINE   APPFOLDER      "C:\myproject\"
>#DEFINE   MYPRGFOLDER    APPFOLDER + "PRGS"
>
>LOCAL APPFOLDER
>
>APPFOLDER = ADDBS(GETDIR())    && User select "C:\MYPROJECT2\"
>?MYPRGFOLDER     && It shows C:\myproject2\PRGS too!!!!
>
>
>I was thinking constant only been evaluated during compile time.
>
>Please advice.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform