Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BCD conversion
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00327853
Message ID:
00328326
Views:
25
Hi Eric.

>Does anyone have a decimal to bcd function?

Here's one I use. In the BCD spec this was written for, numbers were formatted as:

1234 = 01 23 4C
-1234 = 01 23 4D
lparameters tcValue
local lcValue, ;
    lnI, ;
    lnChar
#define ccPOSITIVE 'C'
lcValue = ''
for lnI = 1 to len(tcValue)
    lnChar  = asc(substr(tcValue, lnI, 1))
    lcValue = lcValue + right(transform(lnChar, '@0'), 2)
next lnI
lnValue = val(left(lcValue, len(lcValue) - 1)) * ;
    iif(right(lcValue, 1) = ccPOSITIVE, 1, -1)
return lnValue
Doug
Previous
Reply
Map
View

Click here to load this message in the networking platform