>>What is the simplest explanation as to why these are needed? Why not just set regular variable values? So what if they are constant and don't change?
>
>I don't know if this is the simplest explanation but I use them for two reasons. One is to make the code more readable. To me at least it is more meaningful to look at a command like
>
>lnSalesTax = lnInvoiceTotal * SALES_TAX_RATE
>
>than
>
>lnSalesTax = lnInvoiceTotal * 0.07
>
>That way there are no "magic numbers" in calculations.
>
>The second reason is maintainability. If the tax rate changes, only the #DEFINE statement needs to be changed rather than searching through code and changing 0.07 everywhere it occurs.
>
>Another example is MessageBox() arguments and return values. Which is more clear, 48 or MB_ICONEXCLAMATION? 6 or IDYES? Think about it. There is probably a reason the Fox team declared those constants in FoxPro.H <g>.
>
>Other times I put some defined constants at the top of a program if there seems to be a good chance they will be changed as the program is used. A recent example was a program to report on customers whose percentage of swiped credit card transactions fell below a certain threshold. (Simplified background: there is less chance of error or fraud when the card is swiped through a card reader than keyed manually). The client first guesstimated this percentage at 90% but knew it might be adjusted up or down depending on how many customers were reported (limited number of fraud prevention employees to follow up on the report).
__________
One would swear that Jay has taken on/up programming seriously since he has stoppped spamming the chatter section - ducking
Gregory