Description
Initializes the iterator so that array items may be iterated over by successive calls to CTARR_IterNext.
Prototype
DCTARR_IterStart...
D PR 10I 0
D@This * Value
Parameters
@This
Type | Pointer (*) |
Passing Mode | Value |
Description | The address of an array instance. This pointer MUST be obtained through a call to CTARR_Constructor. |
Return Values
Symbolic Constant | Value | Description |
CS_SUCCESS | 0 | The iterator has been initilized successfully. |
Notes
The CTARR class implements an iterator which allows the caller to navigate the array in sequential index order. An iteration loop is started with a call to CTARR_IterStart. Then, calling CTARR_IterNext successively will return array items in index order, moving up one item with each call until there are no more items in the array. When the CTARR_IterNext method returns CT_FAILURE, this indicates that the iteration has reached the end and no value is returned (This is similar to an index out of range conditoin).
Examples
HDatEdit(*YMD)
*--------------------------------------------------------------
* Common Definitions
*--------------------------------------------------------------
/Include QINCSRC,CTBASE_H
DEntryProc Pr ExtProc('EXLST10')
DEntryProc PI
*-------------------------------------------------------------------------------
* Main
*-------------------------------------------------------------------------------
DArray S *
DBuffer S 32A
/Free
Array = CTARR_Constructor();
// Let's allocate an array of size 3
// And initialize each item with the string
// "HELLO"
Buffer = 'HELLO';
CTARR_Alloc(Array: 3: %Size(Buffer): %Addr(Buffer));
// Look at each item
CTARR_IterStart(Array);
Dow CTARR_IterNext(Array: %Addr(Buffer)) = CT_SUCCESS;
// Do something ...
EndDo;
// Let's assign values ....
Buffer = 'String - 1';
CTARR_Set(Array: %Addr(Buffer): 1);
Buffer = 'String - 2';
CTARR_Set(Array: %Addr(Buffer): 2);
Buffer = 'String - 3';
CTARR_Set(Array: %Addr(Buffer): 3);
// Look at each item
CTARR_IterStart(Array);
Dow CTARR_IterNext(Array: %Addr(Buffer)) = CT_SUCCESS;
// Do something ...
EndDo;
CTARR_Destructor(Array);
*InLr = *On;
Return;
/End-Free