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



On 23 Feb 2013 17:20, Ken Sims wrote:
On Sat, 23 Feb 2013 11:21:57 -0500, John Yeung wrote:

I don't think that's the way to even think about data structures.
RPG is not THAT high-level a language. An RPG data structure is
not an object with arbitrary attributes. It's not a collection of
arbitrary values. It's just a C struct. It's a chunk of memory
that you can overlay some definitions onto.

Exactly.

And while that works out not-so-good for the specific situation in
question, it works out really great for a lot of other things, such
as overlaying a zoned decimal field or array of unsigned integers on
a character field.


While admittedly a contrived example, the following two DS compare as unequal after a change to a Zoned Decimal value just as did the Varying string after a change to the /same/ scalar value, even though all of the subfields compare equal:

H dftactgrp(*no)
D DXA DS 4 Qualified
D Prc 2S00
D Scl 2S00
D DXB DS likeds(DXA)
/Free
*inlr = *on ;
DXA = '150E' ; // an overlay was omitted; assign DS instead
DXB = DXA ;
if DXA.Scl = 5 and DXA.Prc = 15 ; // That's everything!
DSPLY 'Prc=15 and Scl=5 in DXA, and DXB=DXA' ;
DXA.Scl = 5 ; // Already=5, but what the heck! ;-)
endif ;
if DXA.Prc = DXB.Prc and DXA.Scl = DXB.Scl ; // Subfields equal!
DSPLY 'Prc and Scl of DXB and DXA are equal' ;
endif ;
if DXA <> DXB; // Two DS unequal, yet all subfields are equal!
DSPLY '5=5 yet they are not the same' ;
endif ;
/End-free

There are other examples such as mixed [DBCS and SBCS] data and obviously Packed for the same issue as with Zoned shown above, that also could miscompare in a DS, but compare equal in a test of the individual scalars. So to be clear, the nuance is not limited to just Varying.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.