The problem with %int or %dec is the sign. 0M zoned is -4, int or dec report it as error.

Scott Klement wrote:

Hi Alan,

D cvtZonedToInt pr 10i 0 extproc('QXXZTOI')
d cvtZone * value options(*string)
d cvtDigits 10i 0 value
d cvtFraction 10i 0 value

You should remove 'options(*string)' from the first parameter. The input isn't a string, it's a zoned decimal number.

I have no idea why you'd want to use this for your purposes, though. Is your goal really to convert zoned decimal to integer? And if it is, why use a C function? Why not use %int()?

AFIAK, your issue is thast you have bytes in zoned decimal format, but they've been stored (for some weird unknown reason) in an alphanumeric field instead of in a zoned decimal field.

The solution to that is to use overlaid fields in a data structure. Though, you can solve the same problem by passing a mismatched parameter (which is what you've done by calling QXXZTOI) or by pointer logic.

But, an overlaid data structure field would perform a lot better than calling this API, and it'd also make a lot more sense to the next guy reading your program.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].