As I also like to use a linked list where they are appropriate to use I like to make the distinction between a list and a queue. And that working with data queues via API and/or commands is rather cumbersome compared to working with a service program (hopefully nicely written) which lets me work with a linked list.

Here an example for a linked list for System i: http://www.rpgnextgen.com/index.php?content=llist
As you can see most features which are covered by the service program are just not there when working with a data queue (they can be programmed, but are not currently provided).

My 2 cents.

Mihael

-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] Im Auftrag von Charles Wilt
Gesendet: Montag, 11. Mai 2009 21:52
An: RPG programming on the IBM i / System i
Betreff: Re: Debugging and based variables

Adam,

I have to ask....why are you bothering to build your own queue?

My understanding is that queues are an integral (and well optimized)
part of the OS, so why not make use of the built in queue support?

Charles

On Mon, May 11, 2009 at 3:23 PM, Adam Glauser <adamglauser@xxxxxxxxx> wrote:
I am writing an RPG program that uses a linked list to implement an
ordered queue.  I was having trouble trying to browse through the linked
list by dereferencing pointers using the WDSC v7 debugger.

The V5R4 RPG reference[1] tells me that I can dereference pointers using
the ptrName:c syntax.  This is awesome, and works well in WDSC.
However, I couldn't seem to get the ptrName->varName syntax to work.  I
was composing a "help please" request for WDSC-L when I figured it out.
 So I hope this example will be useful for someone else, it should work
similarly in the green screen debugger (which is why I cross posted to
RPG400-L).

Each element in the list looks like
     D listElemType...
     D                 DS                  qualified
     D                                     based(TEMPLATE_ONLY)
     D  next...
     D                                 *
     D  data...
     D                                 *

and each 'data' pointer points to an element of this DS array
     D stay...
     D                 DS                  qualified
     D                                     dim(1000)
     D  trailer...
     D                               15A
     D  yard...
     D                               10A
     D  arriveDate...
     D                                 D
     D  arriveTime...
     D                                4P 0
     D  departDate...
     D                                 D
     D  departTime...
     D                                4P 0
     D  totalMinutes...
     D                                7P 0

Given
     D curElem...
     D                 DS                  likeDS(listElemType)
     D                                     based(pCurElem)

with pCurElem pointing at a valid list element, I can successful monitor
the expression 'curElem.data:c 50'.  'pCurElem->curElem.data:c 50' is
equivalent.
To see the second element of the list, I can use
'pCurElem->curElem.next->curElem.data:c 50', and add in '->curElem.next'
as many times as I need to to view each element in the list.

There are a couple of ways I think this could work better.  I think the
'Monitor Memory' view might simplify things and save some typing, but I
can't quite figure out how to make it work.  The other thing that would
be nice would be the ability to use 'curElem.data->stay' instead of
'curElem.data:c' so that the numeric subfields would be easier to interpret.

HTH,
Adam


[1]
https://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/books_web/c0925076227.htm#Header_290
--
This is the RPG programming on the IBM i / System i (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.



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.