The next part of the template uses a
SELECT/WHEN
construct to extract and write the data-item type. To see how this works, first consider the fact that there are a finite number of values that can be specified fortype
. Turning to thetype
field in the data-item form, you can see that a data-item type can be one of the following:
●
●
●
●The data-item type is referred to as an enumerated type—each of the values for this field is represented by a unique number. These numbers correspond to predefined constants (
stm_di_record
,stm_di_list
, and so on). You use a database extraction function to extract this type for each data-itemdi
in your properties.Next, you want the name of the data-item type to be written in the document. To do this, use a
SELECT/WHEN
construct as shown in the template. This construct selects for execution one of the statements contained between the keywordsSELECT
andEND
SELECT
. Only one of these statements is executed for each data-item. Each statement contains a trigger, beginning with the keywordWHEN
that, when satisfied, leads to the execution of the statement following the arrow. In this template, the triggering condition is the value of the data-item type represented by the variabledi_type
. When this value is equal to that of the particular value of the data-item type contained in theWHEN
statement, aWRITE
statement is executed that inserts a blank line and writes “TYPE:”, followed by the data-item type.Note that you cannot write the data-item type directly from the variable
di_type
that represents it. This is because this variable actually represents an integer value; writing the variable’s value would result in an integer being written, instead of the name of the data-item type. You solve this problem by writing an appropriate string name that corresponds to the variable’s value.