|
Thanks a lot Scott. Finally it is working.
But I have some problems with 1-byte and 8-byte integer data types.
I am trying to declare the fields as
D a S 3I 0
D b S 20I 0
But I am getting the error as "The length of an integer or unsigned field
is not valid." My version is V4R2M0.
I think these 2 data types are not supporting by my release.
Can anyone clarify me which version supports these 2 data types and Is
there other means to use these 2 data types in V4R2M0.
Thanks
Scott Klement
<klemscot@klements. To: RPG programming on the
AS400 / iSeries
com> <rpg400-l@xxxxxxxxxxxx>
Sent by: cc:
rpg400-l-bounces@mi Subject: Re: Bytes Swapping
in iSeries
drange.com
10/02/2004 01:12 PM
Please respond to
RPG programming on
the AS400 / iSeries
Hi Lakshmi,
> I understood what you are saying. My problem is the third party(PC) they
do
> not want to do the bytes swapping, so my end (On AS/400) need to do the
> swapping and send.Is there any other way to do the bytes swapping on
> AS/400.
Oh, so you want to just reverse the order of the bytes from what it is?
That's not hard to do, just copy the bytes from one end to the other end.
Here's a general-purpose routine for reversing the order of bytes in a
field. As you'll see by the example code at the top, it can be used to
reverse integers, character strings, etc. Since it operates on the
underlying bytes, it doesn't matter what type of data the variable is.
It's also deliberately intended to work on any size variable, rather than
hardcoding 2 or 4 bytes, etc.
Here it is:
H DFTACTGRP(*NO)
D Reverse PR
D Input * value
D Output * value
D Size 10I 0 value
D Test1 s 5I 0
D Test2 s 5I 0
D Test3 s 26A
D Test4 s 26A
D Test5 s 10I 0
D Test6 s 10I 0
*
* test1 = 16384 (x'4000')
* test2 will be 64 (x'0040')
*
c eval test1 = 16384
c callp Reverse( %addr(test1)
c : %addr(test2)
c : %size(test1) )
c dsply test2
*
* test3 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
* test4 will be 'ZYXWVUTSRQPONMLKJIHGFEDCBA'
*
c eval test3 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
c callp Reverse( %addr(test3)
c : %addr(test4)
c : %size(test3) )
c dsply test4
*
* Test5 = 2130772483 (x'7F010203')
* Test6 will be 50463103 (x'0302017F')
*
c eval Test5 = 2130772483
c callp Reverse( %addr(test5)
c : %addr(test6)
c : %size(test5) )
c dsply test6
c eval *inlr = *on
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Reverse(): This routine copies the bytes from a input buffer
* to an output buffer in reverse order.
*
* Input = pointer to start of input buffer
* Output = pointer to start of output buffer
* Size = size of input buffer. (output buffer must
* be at least this large as well)
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P Reverse B
D Reverse PI
D Input * value
D Output * value
D Size 10I 0 value
D x s 10I 0
D InByte s 1A based(input)
D OutByte s 1A based(output)
c eval Output = Output + (Size - 1)
c for x = 1 to Size
c eval OutByte = InByte
c eval Input = Input + 1
c eval Output = Output - 1
c endfor
P E
_______________________________________________
This is the RPG programming on the AS400 / 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.
Confidentiality Caution
=======================
Privileged/Confidential Information may be contained in this message. If
you are not the addressee indicated in this message (or responsible for
delivery of the message to such person), you may not copy or deliver this
message to anyone. In such case, you should destroy this message and kindly
notify the sender by reply email. Opinions, conclusions and other
information in this message that is not of an official nature shall be
deemed as neither given nor endorsed by SGX unless indicated by an
authorised representative independent of this message.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.