Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
#DEFINE - Why?
Message
De
31/03/2008 12:20:01
 
 
À
31/03/2008 08:58:30
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01306848
Message ID:
01306992
Vues:
7
Sure, using tables is another way to do this. One disadvantage is that if the table is separate from the .EXE it could potentially become corrupted. Or, if you use a "branding" scheme to try to reduce piracy, someone could "unbrand" your app just by changing the table.

If the table is bound into the .EXE then there's little difference from using .h files. You still have different versions of .EXEs.

With very easy data handling/table support in VFP we have the luxury of doing this sort of thing in different ways :) Other languages aren't so lucky so they pretty much have to use .h files.

>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 !
>>
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform