DSM Template Services Manual
Display-Text Procedures
DSM Template Services Manual—427187-004
2-23
Example
On the next call, the context area contains exactly the same values as when
convert-proc returned from its previous call. When convert-proc notices the
nonzero value of context[0], it must determine how to continue the conversion
operation. You determine how it does so and how you use the context area.
Aside from the zero-nonzero convention with context[0], your procedure can use the
context area any way you choose. The essential element is for the procedure to save
sufficient information to resume processing where it left off. Although the context area
has ten words, many procedures can make do with a one-word value that records the
last element placed in external-value. In most cases, context[0] can do double
duty: acting as the nonzero continuation indicator and saving the one-word value.
When the current call is returning the last segment of the external representation,
convert-proc should return zero as the function result. The values in context can
be anything because they are not used in this case.
Example
Suppose certain tokens in your subsystem ABC have a product version, such as D20,
encoded in a one-word integer. The letter (D, in this case) is in the first byte in ASCII.
The number is in the second byte in binary. To represent such a token type in display
text requires special handling. Custom-formatting procedures are designed to
represent such types. This example describes such a procedure, named
abc_cvt_version, and the steps required to place it in operation.
1. Include the definitions in Example 2-2 within the DDL definition file for subsystem
ABC.
The abc-tkn-task-version token will use the custom-formatting procedure.
2. Link the procedure (abc_cvt_version) to its structure definition (zabc-ddl-version)
by placing this statement in the template source file for subsystem ABC:
FORMAT: abc-ddl-version WITH abc_cvt_version
Example 2-2. DDL Definitions for Custom-Formatting Example
?SECTION zabc-ddl-version
?TALBOUND 0
DEF abc-ddl-version TYPE BINARY 16 UNSIGNED SPI-NULL 0.
TOKEN-TYPE abc-typ-version VALUE IS zspi-tdt-uint
DEF IS abc-ddl-version.
CONSTANT abc-tnm-task-version VALUE IS 17.
CONSTANT abc-val-ext-ssid VALUE IS "URORG.ABC.5".
TOKEN-CODE abc-tkn-task-version
VALUE IS abc-tnm-task-version
TOKEN-TYPE IS abc-typ-version
SSID abc-val-ext-ssid
HEADING "Task Version".