Template Loop Expansion Tokens

 

Template loop expansion tokens are used to insert information about the current template being processed within the context of a template loop into the output stream. Template loop tokens can only be used inside a template loop.

 

Field Loop Token

Description

<TEMPLATE#>

Inserts the 1-based index of the current template within the collection of templates.

<TEMPLATE#_ZERO>

Inserts the 0-based index of the current template within the collection of templates.

<TEMPLATE_ALTNAME>

Inserts the alternate name. Arrays are represented in Synergy format, for example ALTNAME[1]. If no alternate name is available then the real name is used.

Alternates:  <template_altname> <Template_Altname> <Template_altname> <TemplateAltname> <templateAltname>

<TEMPLATE_ARRIVEM>

Inserts the name of the arrive method if present, or by nothing if not.

Alternates:  <template_arrivem> <Template_Arrivem> <Template_arrivem> <TemplateArrivem> <templateArrivem>

<TEMPLATE_BREAK_MODE>

Inserts a value indicating whether the template defines a break field, and if so what type of break field.

Possible Values: "None", "Change", "Always", "Return"  (quotes not inserted)

<TEMPLATE_CHANGEM>

Inserts the name of the change method if present, or by nothing if not.

Alternates:  <template_changem> <Template_Changem> <Template_changem> <TemplateChangem> <templateChangem>

<TEMPLATE_CLASS>

 

Inserts the name of the templates class, if present. Only date, time and user-defined templates can have a class assigned.

 

Possible Values: YYMMDD, YYYYMMDD, YYJJJ, YYYYJJJ, YYPP, YYYYPP, HHMMSS, HHMM, UserAlpha, UserBinary, UserDate, UserNumeric

<TEMPLATE_COL>

Inserts the screen column for placement of field on the screen in a cell-based environment. If the template has a column position specified then this is used, otherwise the default of column 15 is used.

<TEMPLATE_CUSTOM_CONVERT_FUNCTION>

 

Inserts the name of a custom data conversion function associated with a field., if present. Otherwise inserts nothing. The custom convert function should accept a single parameter which is of the actual data type of the real field, and have a return value which is the custom data type as defined by <TEMPLATE_CUSTOM_DBL_TYPE>.

 

Developers can specify a custom value via a special token in the fields user text or long description, like this:

 

CUSTOM_CONVERT_FUNCTION=DivideBy100;

 

The name of the token MUST be specified in upper case and the value MUST be terminated by a semi-colon, as shown above.

 

You can test if a field has a custom convert function specified with <IF CUSTOM_CONVERT_FUNCTION>.

 

For example, if a field is a D5 and you wish to process it as a D5.2 then you might set the following values in the long description:

 

CUSTOM_DBL_TYPE=D5.2;

CUSTOM_SQL_TYPE=DECIMAL(5,2);

CUSTOM_CONVERT_FUNCTION=DivideBy100;

CUSTOM_STRING_FUNCTION=DivideBy100ToString;

 

And the custom convert function might look like this:

 

function DivideBy100, d.

    required in decimalValue, n

proc

    freturn decimalValue / 100.0

endfunction

 

<TEMPLATE_CUSTOM_STRING_FUNCTION>

Inserts the name of a custom data conversion function associated with a field., if present. Otherwise inserts nothing. The custom convert function should accept a single parameter which is of the actual data type of the real field, and have a return value which is the custom data type as defined by <TEMPLATE_CUSTOM_DBL_TYPE> but formatted appropriately into a string value.

 

Developers can specify a custom value via a special token in the fields user text or long description, like this:

 

CUSTOM_STRING_FUNCTION=DivideBy100AsString;

 

The name of the token MUST be specified in upper case and the value MUST be terminated by a semi-colon, as shown above.

 

You can test if a field has a custom convert function specified with <IF CUSTOM_STRING_FUNCTION>.

 

For example, if a field is a D5 and you wish to process it as a D5.2 then you might set the following values in the long description:

 

CUSTOM_DBL_TYPE=D5.2;

CUSTOM_SQL_TYPE=DECIMAL(5,2);

CUSTOM_CONVERT_FUNCTION=DivideBy100;

CUSTOM_STRING_FUNCTION=DivideBy100ToString;

 

And the string convert function might look like this:

 

function DivideBy100ToString, string

    required in decimalValue, n

proc

    freturn %string(decimalValue/100.0)

endfunction

 

<TEMPLATE_DEFAULT>

Inserts the fields default value, if present.

<TEMPLATE_DESC>

Inserts the description of the field.

<TEMPLATE_DESC_DOUBLE>

 

Inserts the description of the field. If any double quote characters are present in the description they are replaced with a single quote.

<TEMPLATE_DESC_SINGLE>

 

Inserts the description of the field. If any single quote characters are present in the description they are replaced with a double quote.

<TEMPLATE_DISPLAY_LENGTH>

 

If the current field has a non-zero display length specified then that length is inserted, otherwise nothing is inserted.

 

<TEMPLATE_DRILLM>

Inserts the name of the fields drill method if present, or by nothing if not.

Alternates:  <template_drillm> <Template_Drillm> <Template_drillm> <TemplateDrillm> <templateDrillm>

<TEMPLATE_DRILL_PIXEL_COL>

Inserts the pixel column for placement of a fields drill button on a form.

Example Output: 275

<TEMPLATE_ENUMBASEVAL>

 

For enumerated fields, inserts the enumerated fields base value. The base value is the value assigned to the first member of the enumeration. For non-enumerated fields nothing is inserted.

 

Note: This token refers to UI Toolkit enumerated fields, which are numeric fields with an enumeration specified via the "Enumerated?" field on the fields Validation tab. This token does NOT refer to fields whose Type is set to Enum on the Field Definition page.

Example Output: 1

<TEMPLATE_ENUMLENGTH>

 

For enumerated fields, inserts the maximum length of the fields’ enumerated values. For non-enumerated fields nothing is inserted.

 

Example Output: 12

<TEMPLATE_ENUMSTEPVAL>

 

For enumerated fields, inserts an enumerated fields step value. The step value is the number that is added to or subtracted from the base value for each of the second and subsequent enumeration members. For non-enumerated fields nothing is inserted.

 

Note: This token refers to UI Toolkit enumerated fields, which are numeric fields with an enumeration specified via the "Enumerated?" field on the fields Validation tab. This token does NOT refer to fields whose Type is set to Enum on the Field Definition page.

Example Output: 1

<TEMPLATE_ENUMWIDTH>

 

Inserts the pixel width for the maximum length of the fields’ enumerated values.

Calculated as the maximum length of the fields enumerated values multiplied by 12 pixels per character. This default character width can be overridden using the -cw command line option.

Example Output: 144

<TEMPLATE_FORMATNAME>

Inserts the name of the fields Repository format, or nothing if no format is specified.

<TEMPLATE_HEADING>

Inserts the fields report heading. If no heading exists then the field prompt is used. If no prompt exists then the fields SQL name is used. Array fields will have the element number appended (e.g. Phone #1).

<TEMPLATE_HELPID>

Inserts the fields help identifier if present.

<TEMPLATE_HYPERM>

Inserts the name of the fields’ hyperlink method if present, or by nothing if not.

Alternates:  <template_hyperm> <Template_Hyperm> <Template_hyperm> <TemplateHyperm> <templateHyperm>

<TEMPLATE_INFOLINE>

Inserts the fields’ information line text if present.

<TEMPLATE_INPUT_JUSTIFICATION>

 

Inserts the input justification of the current field.

 

Possible Values:  Left, Right, Center

<TEMPLATE_INPUT_LENGTH>

Inserts the maximum number of characters that can be typed into a UI input field representing the current field.

For alpha fields the input length is the same as the field size.

For decimal fields the input length will be one byte longer than the field size if the field allows negative values.

For implied decimal fields the input length will be one byte longer than the field size to allow for the entry of a decimal point, and two bytes longer that the field size if the field allows negative values.

For integer fields the input length is based on the maximum number of bytes that are required in order to be able to enter the maximum value supported by the integer field, but bear in mind that this may allow your user to enter a value larger than that supported by the underlying field. For example, an I1 field which allows negative values is capable of storing values in the range of -128 to 127, so the input length for the field is 4, but when used to constrain the length of a UI field this would allows the user to enter a value in the range -999 to 9999.

<TEMPLATE_LDESC>

Inserts the fields long description.

<TEMPLATE_LDESC2>

 

Inserts a pre-processed version of the fields long description. The long description is actually an A1800 field, but the repository UI treats is as if it is a [30]A60 array. This token returns a string in which each element of the array that contains data is included in the resulting string, separated by two spaces.

 

For example, the following array:

 

    LDESC, [30]A60, "Option 1", "", "Option 2", "", "Option 3"

 

Would cause the following data to be inserted:

 

    Option 1  Option2  Option 3

 

<TEMPLATE_LEAVEM>

Inserts the name of the fields leave method if present, or by nothing if not.

Alternates:  <template_leavem> <Template_Leavem> <Template_leavem> <TemplateLeavem> <templateLeavem>

<TEMPLATE_MAXVALUE>

Inserts the maximum value which should be associated with a numeric field. The token should only be used for numeric fields, so you should only use it within an <IF NUMERIC> field loop expression.

<TEMPLATE_MINVALUE>

Inserts the minimum value which should be associated with a numeric field. The token should only be used for numeric fields, so you should only use it within an <IF NUMERIC> field loop expression.

if a field does not allow negative values then a minimum value of 0 will normally be returned. However if the field is also marked as required then a value of 1 is returned.

<TEMPLATE_NAME>

Inserts the name of the field. Array fields are represented in Synergy real array format,  and group fields are represented by a full path.

Example Output:

ACCOUNT_NUMBER
PHONE[3]
ADDRESS.CITY
CONTACT[2].NAME

Alternates:  <template_name> <Template_Name> <Template_name> <TemplateName> <templateName>

<TEMPLATE_NOECHO_CHAR>

Inserts the character that should be used to represent each character typed into a field, in place of the actual character (think password fields).

If the current field being processed is a "no echo" field then the token will be replaced by the no echo character specified in the repository field definition, or by an asterisk (*) if no character is specified. If the field is not a "no echo" field then the token will be replaced by a null string.

<TEMPLATE_PAINTCHAR>

 

Inserts the paint character that would be used to represent each character if the current field is a paint field. The default paint character is an asterisk (*).

<TEMPLATE_PAINTFIELD>

 

Inserts a string indicating whether the current field is a paint field.

 

Possible values:

Yes

No

 

<TEMPLATE_PII_TYPE>

 

If a special "PII_TYPE" token has been added to the fields long description or user defined text field then this token extracts the specific type from that token and inserts it into the generated code.

 

The PII_TYPE token looks like this:

 

PII_TYPE=type;

 

The type  specified can be anything, and that value is what is inserted by this token. Common examples might be:

 

PII_TYPE=CREDIT_CARD_NUMBER;

PII_TYPE=PHONE_NUMBER;

PII_TYPE=SOCIAL_SECUTIRY_NUMBER;

 

<TEMPLATE_PIXEL_COL>

Inserts the pixel column for placement of the field within a UI form. If the field has a column position specified then this is used, otherwise the default of column 15 is used.

A default width of 12 pixels per character is used, and this can be overridden using the -cw command line option.

<TEMPLATE_PIXEL_ROW>

Inserts the pixel row for placement of the field within a UI form. If the field has a row position defined then this is used, otherwise the logical field number (which includes array elements) is used to calculate the default row.

A default height of 25 pixels per row is used, and this can be overridden using the -ch command line option.

<TEMPLATE_PIXEL_WIDTH>

Inserts the pixel width for default sizing of the field when represented as a TextBox.

Calculated as the size of the field in characters multiplied by 12 pixels per character. This default character width can be overridden using the -cw command line option.

<TEMPLATE_POSITION_COL>

 

If the field has a field position specified, this token inserts the column position or offset value. Otherwise nothing is inserted.

<TEMPLATE_POSITION_MODE>

 

Inserts the field position mode of the current field.

 

Possible Values:  None, Absolute, Relative

<TEMPLATE_POSITION_ROW>

 

If the field has a field position specified, this token inserts the row position or offset value. Otherwise nothing is inserted.

<TEMPLATE_PRECISION>

Inserts the precision of an implied-decimal field or an empty string. Only the precision is inserted, with no leading period.

<TEMPLATE_PRECISION0>

Inserts the precision of an implied-decimal field or 0 for non implied decimal fields.

 

<TEMPLATE_PRECISION2>

Inserts the precision of an implied-decimal field including a leading period, or an empty string.

<TEMPLATE_PROMPT>

Inserts the fields prompt.

<TEMPLATE_PROMPT_COL>

 

Inserts the screen column for placement of the prompt on the screen in a character based environment. If the prompt has a column position specified in the repository then that value is used, otherwise the default of column 1 is used.

 

<TEMPLATE_PROMPT_PIXEL_COL>

 

Inserts the pixel column for placement of the prompt on a windows form. If the prompt has a column position specified then this is used, otherwise the default of column 1 is used.

 

A default width of 12 pixels per character is used, and can be overridden using the -cw command line option.

<TEMPLATE_PROMPT_PIXEL_ROW>

 

Inserts the pixel row for placement of the prompt on a windows form. If the prompt has a row position defined then this is used, otherwise the logical field number (which includes array elements) is used to calculate the default row.

 

A default height of 25 pixels per row is used, and can be overridden using the -ch command line option.

<TEMPLATE_PROMPT_PIXEL_WIDTH>

 

Inserts the pixel width for default sizing of the prompt when represented as a label.
 

Calculated as the size of the prompt in characters multiplied by 12 pixels per character. This default character width can be overridden using the -cw command line option.

<TEMPLATE_PROMPT_POSITION_COL>

 

If the field has a prompt position specified, this token inserts the column position or offset value. Otherwise nothing is inserted.

<TEMPLATE_PROMPT_POSITION_MODE>

 

Inserts the prompt position mode of the current field.

 

Possible Values:  None, Absolute, Relative

<TEMPLATE_PROMPT_POSITION_ROW>

 

If the field has a prompt position specified, this token inserts the row position or offset value. Otherwise nothing is inserted.

<TEMPLATE_PROMPT_ROW>

 

Inserts the screen row for placement of the prompt on the screen in a character based environment. If the prompt has a row position defined in the repository then that value is used, otherwise the logical field number (which includes array elements) is used to calculate the default row.

 

<TEMPLATE_RANGE_MAX>

Inserts the numeric fields’ maximum value.

<TEMPLATE_RANGE_MIN>

Inserts the numeric fields’ minimum value.

<TEMPLATE_REGEX>

Inserts a regular expression that can be used to constrain and validate user input to a field based on the repository definition of the field. The regular expression inserted depends on the type of field.

Nature of field

Regular Expression

Description

A4

 ^.{0,4}$

Allows between 0 and 4 characters.

A4, required field

 ^.{1,4}$

Allows between 1 and 4 characters.

D4, no negatives

 ^[+]?[0]*[0-9]{0,4}$

Allows an optional + sign, followed by any number of leading zeros, followed by up to four numeric digits.

D4, allows negatives

 ^[+-]?[0]*[0-9]{0,4}$

Allows an optional + or - sign, followed by any number of leading zeros, followed by up to four numeric digits.

D4.2, no negatives

 ^[+]?[0]*[0-9]{0,2}(\.[0-9]{0,2}[0]*)?$

Allows an optional + sign, followed by any number of leading zeros, followed by up to two numeric digits, followed by an optional decimal point. If a decimal point is found then up to two numeric digits may follow, followed by any number of trailing zeros.

D4.2, allows negatives

 ^[+-]?[0]*[0-9]{0,2}(\.[0-9]{0,2}[0]*)?$

Allows an optional + or - sign, followed by any number of leading zeros, followed by up to two numeric digits, followed by an optional decimal point. If a decimal point is found then up to two numeric digits may follow, followed by any number of trailing zeros.

I4, no negatives

 ^[+]?[0]*[0-9]{0,10}$

Allows an optional + sign, followed by any number of leading zeros, followed by up to ten numeric digits.

I4, allows negatives

 ^[+-]?[0]*[0-9]{0,10}$

Allows an optional + or - sign, followed by any number of leading zeros, followed by up to ten numeric digits.

In the table above, the numbers shown in red are based on the size of the field being processed at the time.

Integer Fields

The regular expression for integer fields will constrain the number of characters entered, and restrict those characters to being numeric characters, but it will NOT restrict the user to only entering valid numeric values. For example, an i1 field can store up to 127, the regular expression will constrain the entry to 3 numeric characters but it will still be possible to enter an out of range value (e.g. 256).

Required Fields

Currently CodeGen only takes a fields "required" status into account for alpha fields. If an alpha field is required then the regular expression produced will require at least one character be present.

<TEMPLATE_REPORT_JUSTIFICATION>

 

Inserts the report justification of the current field.

 

Possible Values:  Left, Right, Center

<TEMPLATE_ROW>

Inserts the screen row for placement of the field on the screen in a cell based environment. If the field has a row position defined then this is used, otherwise the logical field number (which includes array elements) is used to calculate the default row.

<TEMPLATE_SAMPLE_DATA>

 

Inserts sample date for the field. This token is intended to be used for the generation of examples in documentation or API references.

 

The token first looks in the long description data for sample data defined like this:

 

    SAMPLE_DATA=123 Main Street;

 

If found then the value between SAMPLE_DATA= and the semi-colon is inserted. If not found then an appropriate generic value (ABC or 123, etc.) is inserted.

 

Sample data for alpha variables is surrounded by double quotes.

 

NOTE: This token only currently works with basic field types alpha, decimal, implied decimal, integer and boolean. For other field types nothing is inserted.

 

Possible Values:  "ABC", 123, 1.23, True, "Sample "

<TEMPLATE_SAMPLE_DATA_NOQUOTES>

 

Inserts sample date for the field. This token is intended to be used for the generation of examples in documentation or API references.

 

The token first looks in the long description data for sample data defined like this:

 

    SAMPLE_DATA=123 Main Street;

 

If found then the value between SAMPLE_DATA= and the semi-colon is inserted. If not found then an appropriate generic value (ABC or 123, etc.) is inserted.

 

Sample data for alpha variables is NOT surrounded by double quotes.<TEMPLATE_SELECTIONS1>

 

NOTE: This token only currently works with basic field types alpha, decimal, implied decimal, integer and boolean. For other field types nothing is inserted.

 

Possible Values:  ABC, 123, 1.23, True, Sample

<TEMPLATE_SELECTION_COUNT>
 

Inserts the number of selection list values that are associated with the field. A value of 0 will be inserted for fields that do not have associated selection lists.

 

Example: 4

 

<TEMPLATE_SELECTIONS>

If the field has a selection list defined, this token inserts a comma separated and quoted list of the fields’ selection list values, otherwise nothing is inserted.

Example: "Red","Green","Blue"

<TEMPLATE_SELECTIONS1>

If the field has a selection list defined, this token inserts a quoted string containing a pipe (|) delimited list of the fields selection list values, otherwise nothing is inserted.

Example:  "Red|Green|Blue"

<TEMPLATE_SELECTIONS_COL>

 

If the field has a selection list or selection window and selection column defined, this token inserts the column position for the placement of the selection window. Otherwise nothing is inserted.

<TEMPLATE_SELECTIONS_HEIGHT>

 

If the field has a selection list defined, this token inserts the maximum height in rows that the generated selection window should occupy vertically. Otherwise nothing is inserted.

<TEMPLATE_SELECTIONS_ROW>

 

If the field has a selection list or selection window and selection row defined, this token inserts the row position for the placement of the selection window. Otherwise nothing is inserted.

<TEMPLATE_SELLENGTH>

Inserts the maximum length of the fields’ selection list values.

<TEMPLATE_SELWND>

Inserts the name of the selection window associated with the current field, always in uppercase.. If the field does not have a selection window then the token inserts nothing.

Bear in mind that if the -ws command line option is being used then CodeGen may have removed the selection window name from the field definition and replaced it with a selection list, based on the selection windows entries. In that case you can use a <SELECTION_LOOP> to process the selections.

Alternates:  <template_selwnd> <Template_Selwnd> <Template_selwnd> <TemplateSelwnd> <templateSelwnd>

Note that in repository the name of a fields selection window can be entered in a mixed case format. The <TEMPLATE_SELWND_ORIGINAL> token allows you to use the name of the selection window exactly as it appears in the repository.

<TEMPLATE_SELWND_ORIGINAL>

 

Inserts the name of the selection window associated with the current field exactly as defined in the repository (might be mixed case). If the field does not have a selection window then the token inserts nothing.

 

<TEMPLATE_SIZE>

Inserts the size of the field in bytes.

<TEMPLATE_PARENT_TEMPLATE>

Inserts the name of the Repository template from which the field inherited its attributes or by a null string if no template is referenced.

<TEMPLATE_TKSCRIPT>

Inserts a UI Toolkit .field script file command for the field.

<TEMPLATE_USER_TYPE>

 

For user-defined fields, inserts the fields user defined field type string, if present, otherwise inserts nothing.

<TEMPLATE_UTEXT>

Inserts the fields’ user-defined text string.

<TEMPLATE_VIEW_LENGTH>

 

If the current field has a non-zero view length specified then that length is inserted, otherwise nothing is inserted.

 

 

 

 


Copyright © 2021  Synergex International, Inc.