Utility Functions : List of Utility Functions : stm_list_sort_by_attr_value

stm_list_sort_by_attr_value

Function type: LIST OF ELEMENT

Description
Sorts the specified list of Statemate elements by the value of the given attribute.
Note that the function receives and returns a list of element IDs, not a list of element names.
Syntax
stm_list_sort_by_attr_value (list, attr_name, status)
Arguments
 
The function returns the status code stm_elements_without_attributes if you apply this function to a list of elements that do not have the specified attribute.

 

Status Codes
Example
Suppose you want to write a particular list of activities from the database to your document. You extract the activities of interest using single-element and query functions and build a list of such activities. This list is assigned to the variable act_list. To sort the activities by the value of an attribute called “code”, your template should contain the following function calls:

VARIABLE
LIST OF ACTIVITY act_list, ord_act_list;
ACTIVITY activ;
INTEGER status;
.
.
.
ord_act_list := stm_list_sort_by_attr_value (act_list,
’code’, status);
WRITE (’\n Ordered list of activities:’);
FOR activ IN ord_act_list LOOP
WRITE (’\n’, stm_r_ac_name (activ, status));
END LOOP;