|
On Fri, 17 Oct 2003, Joel Cochran wrote: [SNIP] > d QRecLen 4b 0 [SNIP] > d bytesReturned 4b 0 > d bytesAvail 4b 0 [SNIP] > > The problem is that the data is off by a few characters. Here are the > results in debug: Hi Joel, The BINARY(4) specified in the API manuals is referring to a 4-byte binary integer. Emphasis should go on the word "byte." "4b 0" in RPG is a 4-digit binary integer. Emphasis should be on the word "digit." 4b0 is only 2 bytes long. So... first of all, your parameter list is wrong. the "4b 0" should be either be "9b 0" or (better) "10I 0". Also, the data structure needs to be changed to "10I 0" in place of every "4B 0." Furthermore, the "B" data type is limited. It does work as a binary data type, but it truncates numbers to decimal digits, instead of to binary digits (i.e. bits.) Therefore, a 9B 0 maxes out at 999999999 whereas a 10I 0 (which is true binary) can do 2147483647 as it's highest value. The "10I 0" also performs better (because "B" converts to packed for any arithmetic, whereas true binary math can be done on "I") Therefore, I recommend that you always use the "I" or "U" data types, and never use the "B" data type. But, "B" WILL work, as long as you specify one that's actually 4 bytes rather than 4 digits :) This is a FAQ. (In fact, it could be the most commonly asked question on this list) please see the Midrange FAQ for more details: http://faq.midrange.com/data/cache/24.html Hope that helps
As an Amazon Associate we earn from qualifying purchases.
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.