Utility Functions : List of Utility Functions : stm_list_next_element

stm_list_next_element

Function type: ELEMENT

Description
Returns the next item in the specified list. This function can be applied to a list of any DGL data type.
Note that “next” refers to the item physically located after the current item in the list. The “current” item is determined using the utility function stm_list_first_element.
Syntax
stm_list_next_element (list, status)
Arguments
 
Items in the input list can be of any element type except string. For strings, see the function stm_str_list_next_element.

 

Status Codes
Example
Assume you have a list of states in the order S1, S2, S3 and S4. The list is assigned to the variable state_list. You locate the state S1 by calling stm_list_first_element. S1 becomes the “current’ item. To find the next element in the list, use the following statements:

VARIABLE
LIST OF STATE state_list;
STATE state_id;
INTEGER status;
.
.
state_id := stm_list_first_element (state_list, status);
WRITE (’\n The first state in the list is: ’,
stm_r_st_name (state_id, status));
state_id := stm_list_next_element (state_list, status);
WRITE (’\n The second state in the list is: ’,
stm_r_st_name (state_id, status));
.
.

This function is often used in loop statements.