× 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.



Are you aware that below a certain length a varying string has a 2 byte length and above that length it has a 4 byte length? Could this be the source of the problem in the intermediate steps of the calculation?

Thanks,

Marvin
No trees were killed in the sending of this message, but a large number of electrons were terribly inconvenienced, traumatized, triggered, and crying for their safe spaces.

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of j.beckeringh@xxxxxxxxxxxxxxxxxxxxxxxxxx
Sent: Wednesday, March 07, 2018 7:06 AM
To: RPG programming on the IBM i (AS/400 and iSeries) <rpg400-l@xxxxxxxxxxxx>
Subject: Re: Strange problem (bug?) varying fields

Kristof,

I can confirm your findings; the same thing happens on V7R3M0.

It appears to be happening when the temporary variable is constructed for the call to TestEncode. In debug you can see that what TestEncode receives is incorrect. Hex:

00000 001A0000 00000000 001AA340 C195A388 - ..........t Anth
00010 969589A2 40D29989 A2A39686 00000000 - onis Kristof....

It starts with '001A' - length of 26. But the following hexadecimal zeros are not characters.

Definitely a bug.

Joep Beckeringh
Software Architect
Pantheon Automatisering B.V.
Heerenveen



Kristof Anthonis <Kristof.Anthonis@xxxxxx>

07-03-2018 15:06

Strange problem (bug?) varying fields

Hello,

I have a very strange problem using varying fields in RPG. We are
running on V7R2.

I 've defined these three fields:


d Wrk_XML s a len(131064) varying
d Wrk_S1 s a len(5000) varying
d Wrk_S2 s a len(5000) varying
I than run the following code. The TestEncode function does not in
particular here, but in the real business case I want to do something
there. This is just to show te problem.

Wrk_XML = '';
Wrk_S1 = 'Anthonis';
Wrk_S2 = 'Kristof';
Wrk_XML = Wrk_XML + '<Subject>' +
TestEncode(
'LabResult ' +
Wrk_S1 + ' ' + Wrk_S2) +
'</Subject>';
p TestEncode b
d TestEncode pi a len(5000) varying
d pi_s a len(5000) const varying
/free
Return pi_s;
/end-free
p TestEncode e
The result in Wrk_XML = <Subject> t Anthonis Kristof</Subject>
So, that is not correct.

When I change the definition of WRK_XML to

d Wrk_XML s a len(131063) varying

The result in WRK_XML = " <Subject>LabResult Anthonis Kristof</Subject>"
That is correct.

Can anyone explain this: why is this working ok for a length of
131063 or less, and not ok for 131064 and above?

Thanks for any answers!!
Kristof Anthonis
--
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: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at https://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link: http://amzn.to/2dEadiD
Notice: This e-mail transmission may contain information that is proprietary, privileged and/or confidential and is intended exclusively for the person(s) to whom it is addressed. This message may also contain Protected Health Information (PHI) and must be treated confidentially and handled in accordance with HIPAA and other federal and state privacy laws. Any use, copying, retention or disclosure by any person other than the intended recipient or the intended recipient's designees is strictly prohibited. If you are not the intended recipient or their designee, please notify the sender immediately and delete this e-mail (and any accompanying attachments).

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.