IBM AS/400 User Manual Page 144

  • Download
  • Add to my manuals
  • Print
  • Page
    / 489
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 143
Managing Dynamically-Allocated Storage
procedures in the module DYNARRAY dynamically allocate storage for a practically
unbounded packed array. The procedures in the module perform the following
actions on the array:
¹ Initialize the array
¹ Add an element to the array
¹ Return the value of an element
¹ Release the storage for the array.
DYNARRAY performs these actions using the three ILE bindable storage APIs,
CEECRHP (Create Heap), CEEGTST (Get Storage), and CEEDSHP (Discard
Heap), as well as the REALLOC operation code. See the
System API Reference
for specific information about the storage management bindable APIs.
Figure 54 shows the /COPY file DYNARRI containing the prototypes for the proce-
dures in DYNARRAY. This /COPY file is used by the DYNARRAY module as well
as any other modules that call the procedures in DYNARRAY.
DYNARRAY has been defined for use with a (15,0) packed decimal array. It could
easily be converted to handle a character array simply by changing the definition of
DYNA_TYPE to a character field.
*=================================================================
* DYNARRAY : Handle a (practically) unbounded run-time
* Packed(15,0) array. The DYNARRAY module contains
* procedures to allocate the array, return or set
* an array value and deallocate the array.
*=================================================================
D DYNA_TYPE S 15P 0
D DYNA_INIT PR
D DYNA_TERM PR
D DYNA_SET PR
D Element VALUE LIKE(DYNA_TYPE)
D Index 5I 0 VALUE
D DYNA_GET PR LIKE(DYNA_TYPE)
D Index 5I 0 VALUE
Figure 54. /COPY file DYNARRI containing prototypes for DYNARRAY module
Figure 55 on page 121 shows the beginning of module DYNARRAY containing the
Control specification, and Definition specifications.
120 ILE RPG for AS/400 Programmer's Guide
Page view 143
1 2 ... 139 140 141 142 143 144 145 146 147 148 149 ... 488 489

Comments to this Manuals

No comments