Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Constants vs Locals
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00269906
Message ID:
00270784
Views:
27
>Is there any reason to use a #DEFINEd constant instead of a local var? I've seen it done, but am not aware if the rationale, particularly when trying to debug...


Bruce, here is a slightly different way that I use DEFINEs: to access elements in an array. The defines enable me to refers to different array positions with meaningful names.

I know there is a strong trend to tables and cursors and away from arrays, but I still find situations where an array gives me better control on what is happening.

Peter





** declare an array and a local variable:

local lnIT1

private array paItems [1,1]

#define hcPriority paItems[lnIT1,1]
#define hiAITEMS paItems[lnIT1,2]
#define hcItemType paItems[lnIT1,3]
#define hyAmount paItems[lnIT1,4]
#define htEffective paItems[lnIT1,5]


** Fill the array from an SQL select



** Code sample:

for lnIT1 = 1 to alen(paItems,1)
if hyAmount < 0 && credit
lyTotalCR = lyTotalCR - hyAmount && + value
if lyTotalCR >= lySmallChg
ltClose = htEffective
exit
endif
else && debit
if hyAmount < lySmallChg
lySmallChg = hyAmount
endif
if lyTotalCR >= lySmallChg
ltClose = htEffective
exit
endif
endif
endfor
Peter Robinson ** Rodes Design ** Virginia
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform