The next part of the template segment gives instructions for writing each element’s type (event, condition, or data-item), followed by its name. To do this, use a
FOR/LOOP
construct to both extract an elementelm
out of the alphabetizedin_list
and perform several statements iteratively.The first statement in the loop extracts the type of the element represented by the variable
elm
. The template then uses aSELECT/WHEN
construct to write the element type and name. The triggers of theWHEN
statements are constructed so when the variableelm_type
is equal to a particular element type, theWRITE
statement to the right of the arrow is executed.“Element type” is referred to as an enumerated type; each of the possible values is represented by a unique number. These numbers correspond to predefined constants (
stm_event
,stm_condition
, andstm_data_item
). Note that the template does not use the value of the variableelm_type
to write the element type; doing so would cause the integer value to be written. Instead, the template writes the string that corresponds to the integer value.You must use a database extraction function in the
WRITE
statements to produce the elements’ names because the variableelm
that represents the individual element (as well as the list of elements represented by the variablein_list
) consists of element IDs, rather than names. To produce the element’s names, use the IDs as parameters in a database extraction function that returns element names.After the
WHEN
construct is executed and the element’s type and name is written, the program loops back to the beginning of theFOR/LOOP
and the instructions are carried out for another element. This continues until all input elements are written.The last part of the template constructs lists of output elements and writes their types and names. This part is identical for that of input elements, except that a different function is used to build the output a-flow-line elements.