IBM AS/400 manual Managing Dynamically-Allocated Storage, Part, Running a Program117

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 141
Image 141

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 poin￿ter 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 Program117

Page 141
Image 141
IBM AS/400 manual Managing Dynamically-Allocated Storage, Part, 4 of 5. Memory Management - Build a Linked List of Names