Utility Functions : List of Utility Functions : stm_list_previous_element

stm_list_previous_element

Function type: ELEMENT

Description
Returns the previous element in the specified list. This function can be applied to a list of any DGL data type.
Note that “previous” refers to the item physically located before the current item in the list. The “current” item is determined using the utility function stm_list_last_element.
Syntax
stm_list_previous_element (list, status)
Arguments
 
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 S4 by calling stm_list_last_element. S4 becomes the “current” item. To find the previous element in the list, use the following statements:

VARIABLE
LIST OF STATE state_list;
STATE state_id;
INTEGER status;
.
.
state_id := stm_list_last_element (state_list, status);
state_id := stm_list_previous_element (state_list,
status);
WRITE (’\n State of interest is: ’,
stm_r_st_name (state_id, status));
.
.

This function is often used in loop statements.