× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



>When I substring out the binary
>(4 positions in the buffer) to a 4
>alpha field and try to move it
>to a 9b 0 field, my program blows up.

The binary conversion might be easier to do than the packed conversion, but
neither is too terrible.

D* Convert binary to decimal
D Binary4         DS                  Inz
D  Binary4Chr1            1      1
D  Binary4Chr2            2      2
D  Binary4Chr3            3      3
D  Binary4Chr4            4      4
D  Binary4Dec             1      4i 0

eval Binary4Dec = 0
eval Binary4Chr4 = singleByte
eval digit = Binary4Dec

Now, if this is the low order byte, save the number:
eval number = digit

If this is the next higher order byte, multiply it by 256 (2 to the 8th) and
increment:
eval number = number + (digit * 256)

If this is the next highest, multiply by 65536 and increment and so on.  I
haven't got a code sample I'm able to share with the public, sorry.

I posted a bit of code for testing packed number validity to the RPG list in
Jan 2001.  See that post in the archives http://archive.midrange.com and the
follow-up where Barbara Morris kindly corrected my mistakes AND made some
very good constructive comments on improving things.
  --buck


As an Amazon Associate we earn from qualifying purchases.

This thread ...


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

This mailing list archive is Copyright 1997-2024 by midrange.com 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].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.