×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.




See below announcement from jacobus erps (already posted to the RPG
list). I've just updated the open source wiki with a link to the
GitHub repo for the project.

Thanks!

On Sun, Jul 23, 2017 at 4:10 AM, John Yeung <gallium.arsenide@xxxxxxxxx>
wrote:

[Crossposted to RPG400-L and OPENSOURCE]

See below announcement from jacobus erps (already posted to the RPG
list). I've just updated the open source wiki with a link to the
GitHub repo for the project.

John Y.


On Sat, 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
--
This is the IBMi Open Source Roundtable (OpenSource) mailing list
To post a message email: OpenSource@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/opensource
or email: OpenSource-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/opensource.


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