Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
#DEFINE - Why?
Message
De
31/03/2008 14:44:04
 
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:
01307090
Vues:
9
>Not a very good example, only the TaxPercentage would be vible for a #define, since the other values are not constants.

Not sure what you mean - the following works as expected:
#DEFINE TaxAmount       _0lO1Ol
#DEFINE InvoiceSubTotal _0lOlOl
#DEFINE TaxPercentage   _0lO1O1

* At runtime, set the values to whatever you want,
* or get a return value from a function, or pass them in as parameters, ...
InvoiceSubTotal = 25
TaxPercentage = 0.12

TaxAmount = InvoiceSubTotal * TaxPercentage

?TaxAmount  && 3
>>You can use #DEFINEs to actually obfuscate your code. Suppose you have some nice readable source code:
>>
>>TaxAmount = InvoiceSubTotal * TaxPercentage
>>
>>Now, let's get cute:
>>
>>#DEFINE TaxAmount         _0lO1Ol
>>#DEFINE InvoiceSubTotal   _0lOlOl
>>#DEFINE TaxPercentage     _0lO1O1
>>
>>What actually gets compiled into your .EXE is
>>
>>_0lO1Ol = _0lOlOl * _0lO1O1
>>
>>So, if someone ReFoxes your code, that's all they get. It makes their life a LOT harder, trying to reverse-engineer your application.
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