|
On Wed, 2014-10-15 at 15:35 -0400, Barbara Morris wrote:
On 2014-10-15 11:09, Gary Thompson wrote:
Birgitta, I guess the conversion to 'packed' happens during the API call (the
compile listing shows B(4,0) )
The binary field wouldn't be converted to packed for the API call. The
address of the binary field would be passed to the API which would then
look at the storage of the binary field followed by the next 2 bytes of
storage. If the binary field had the value 4096 (x'1000') and the
following 2 bytes were x'0000', the API would see the 4-byte binary
value x'10000000' which is decimal 268435456.
Interesting how my "belief" that the field type was internally incorrect
(PD) was completely wrong... even if the logical aspect of the corrupted
data held true and its resolution was to, back in the day, pass a "char"
field mapped over a B field. I guess I failed to look into it deeply
enough, and instead made an assumption, that while incorrect resolved
the problem.
Binary fields are only converted to/from packed when they are used in
calculations. For example, if you have a 4B0 field NUM, and code
NUM = NUM + 1
the compiler defines a 4P0 temporary, call it temp4p.
temp4p = NUM
add 1 to temp4p
NUM = temp4p
If NUM was a 5I, the compiler would just add 1 to NUM directly.
--
Barbara
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
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.