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



Looks really interesting Jacobus - I'll certainly be downloading and giving it a test drive.

One immediate comment though - why oh why such terse names? the meaning of rm_ really doesn't jump out at you. And frankly the function names within the set aren't much better. I can understand there's a bi of an argument to be made for sticking to things like rm_sll - although personally I would still much prefer something like rpgmap_setLowerLimiit. I know I can rename it all to my hearts content but that would kind of defeat the purpose of a standard library.

Am I alone in this or did others have a similar reaction when they saw this?


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On Jul 22, 2017, at 3:43 AM, jacobus erps <jacobus.erps@xxxxxxxxx> wrote:

Hi All,

Compared with more dynamic languages RPG has no dynamic data structures or
collection types such as lists, maps/dictionaries, etc. To be able to also
use dynamic data structures in RPG i created an implementation of a
key/value store, with ordered keys, for RPG (i.e. ILE RPGIV). Like a Java
TreeMap or a PHP associative array. The implementation has a rich API. The
project is on github.com/jerps/RpgMap. Complete docs are at
jerps.nl/RpgMap/Docs/index.html. Using RpgMap is simple. Just install
library RPGMAP (no dependencies), add "bnddir('RPGMAP/RPGMAP')" to the
control spec, and /include the header file (see the docs).

There is no ready compiled library to download, yet, so for now RpgMap
needs to be built from source, which is straightforward. However, a current
ILE RPG compiler is needed. It needs to support the new on-exit opcode
(i.e. 7.2 TR5).

A quick example:

Create a map with 3 key/item pairs, the keys are all dates and the values -
called "items" - are all integers:
map = rm_m(
rm_d( d'2017-07-01' ) : rm_i( 1 ) :
rm_d( d'2017-07-02' ) : rm_i( 2 ) :
rm_d( d'2017-07-03' ) : rm_i( 3 ) );

Insert two key/item pairs into the same "map" (character key, packed
decimal item):
rm_ins(map :
rm_a( 'a' ) : rm_p( 10.20 ) :
rm_a( 'b' ) : rm_p( 20.40 ) );

Iterating through key/item pairs is done using cursors, which support
set-lower-limit, set-greater-than, read, read-previous, etc, semantics.
Iterate through the key/item pairs starting with 'a', and stop until last
pair or when the current key is greater than 'zzz'. Display each key/item
pair.
cur = rm_sll(rm_cur(map):rm_a('a')); // create cursor, set-lower-limit on
'a'
dow rm_rdn(cur:*null:rm_a('zzz')); // read-next (until key greater than
'zzz')
dsply ( rm_a_(rm_key(cur)) + ': ' + %char(rm_p_(rm_itm(cur))) );
enddo;

Dispose "map" (and its contents) and implicitly dispose "cur".
rm_dis(map);
--
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.

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


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.