IBM AS/400 Frozen Dessert Maker User Manual


 
Managing Dynamically-Allocated Storage
*-----------------------------------------------------------------*
* Display - display the list *
*-----------------------------------------------------------------*
P Display B
D saveElem@ S *
D dspName S 40A
*-----------------------------------------------------------------*
* Save the current elem pointer so the list can be restored after *
* being displayed and set the list pointer to the beginning of *
* the list. *
*-----------------------------------------------------------------*
C EVAL saveElem@ = elem@
C EVAL elem@ = %ADDR(first)
*-----------------------------------------------------------------*
* Loop through the elements of the list until the next pointer is *
* *NULL *
*-----------------------------------------------------------------*
C DOW next@ <> *NULL
C EVAL elem@ = next@
C EVAL dspName = %SUBST(nameVal:1&gml.name_len)
C 'Name: ' dsply dspName
C ENDDO
*-----------------------------------------------------------------*
* Restore the list pointer to its former place
*-----------------------------------------------------------------*
C EVAL elem@ = saveElem@
P Display E
Figure 52 (Part 4 of 5). Memory Management - Build a Linked List of Names
Chapter 9. Running a Program 117