Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
#DEFINE - Why?
Message
From
31/03/2008 08:58:30
 
 
To
31/03/2008 01:42:16
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01306848
Message ID:
01306901
Views:
9
PFJI, but I always wonder which is best for this scenario: using *.h files or constants from a table.

*.h files have the advantage or being faster to run because the constants are fixed at compile time, but it also mean that you have multiple versions of the EXE to build, test and deploy.

Using a table is simplier to deploy because you only have one EXE. The user can also change the language with a simple option in the menu. The downside is that it may be slower than with the *.h files because the data is read at runtime instead of at compile time.

My preference goes for the table because of it's flexibility and the single EXE, but I'm curious as to why *.h files would be better (other than the performance reason).

Of course I would use *.h files for other constants used in the application. I've set up my editor colors so that strings and numbers would stand up from the rest of the code so that it give me a reminder that theses strings and numbers should be #DEFINEd.

>Here's one thing they're useful for:
>
>Suppose you have an application you're selling, to multiple registered companies/users and in multiple languages. #DEFINEs let you do this without changing your source code.
>
>#INCLUDE Language.h
>#INCLUDE CompanyInfo.h
>
>...
>
>[Language_ENU.h]
>#DEFINE SomeCharString "English Message"
>
>[Language_ESP.h]
>#DEFINE SomeCharString "Spanish Message"
>
>[Company1Info.h]
>#DEFINE CompanyName "Some Company"
>
>[Company2Info.h]
>#DEFINE CompanyName "A Different Company"
>
>* To regenerate your application for Company2 in Spanish:
>- Overwrite Language.h with Language_ESP.h
>- Overwrite CompanyInfo.h with Company2Info.h
>- Recompile All, et voila !
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform