Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
#DEFINE - Why?
Message
De
31/03/2008 16:23:01
 
 
À
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:
01307135
Vues:
10
>>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
>
>
Sorry. I don't understand how this works.
#DEFINE TaxAmount       _0lO1Ol
#DEFINE InvoiceSubTotal _0lOlOl
#DEFINE TaxPercentage   _0lO1O1

CLEAR

* 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   && Doesn't this equate to _0lO1Ol = 25
? _0lO1Ol              && but this generates an error

TaxPercentage = 0.12   && Doesn't this also equate to _0lO1Ol = 25
? _0lO1Ol              && but this generates an error

TaxAmount = InvoiceSubTotal * TaxPercentage
&&  Shouldn't this equate to  _0lO1Ol = _0lO1Ol * _0lO1Ol
&&  or expand to _0lO1Ol = .12 * .12

? taxamount
?invoicesubtotal
?taxpercentage
? _0lO1Ol 
but the last four lines print the values assigned. If each constant is assigned the same value (_0lO1Ol), why do invoicesubtotal and taxpercentage have different values when it comes time to print them?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform