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



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

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.