Format Templates
- Last UpdatedJul 18, 2023
- 2 minute read
The format of a format template string is:
[text]{<name>[,width[,justification]]}[text]...
Rules for valid format template display
-
If the "width" value is not present then the width is set to the length of the number of characters inclusive between '{' and '}'. This means that the field value may be truncated or padded depending on the name value length.
-
If the "width" value is specified then that is the length of the field. This means that the name value length may be truncated or padded.
-
The justification is made up of a single character with the following behaviours as specified:
-
'R' or 'r' will align the field on the right hand side. If the width is longer than the name value length then the left hand side of the name value is padded with spaces.
-
'L' or 'l' will align the field on the left hand side. If the width is longer than the name value length then the right hand side of the name value is padded with spaces.
-
'Z' or 'z' will align the field on the right hand side. If the width is longer than the name value length then the left hand side of the value is padded with zeros.
-
'N' or 'n' will remove any extra padding that is used. Essentially any padding of the name value is trimmed.
-
-
If a justification is not specified then the name value is assumed to be left justified.
-
Any spaces appearing after the first comma onwards in the format template will be stripped out at no penalty to the user.
Malformed format template display
There are two types of malformed templates and below are examples of each and the resulting output.
-
Internal malformation
This is when there is a correct open and close bracer '{' and '}' but inside the format template there is a malformation. For example there may be a space not a comma separating the name and the width. In this case the whole field is ignored which means nothing between and including '{' and '}' is displayed.
For example, take the following string:
< { LocalTimeDate , 20 , R } > TagLabel < { Tag , 20 L } > DescriptionLabel < {
Desc , 20 , L } >The output would as follows:
< 2009-07-17 11:13:17 > TagLabel < > DescriptionLabel < ValidAlarm1Desc >
Note: The "Tag" name value is not outputted as the field has no ',' between the width and justification.
-
Bracer malformation
This is when there is an open bracer '{' but no closing bracer '}'. In this case the malformation is printed as a string literal.
For example, take the following string:
< { LocalTimeDate , 20 , R } > TagLabel < { Tag , 20 , L > DescriptionLabel < {
Desc , 20 , L } >The output would be as follows:
< 2009-07-17 11:31:44 > TagLabel < { Tag , 20 , L > DescriptionLabel <
ValidAlarm1Desc >Note: The "Tag" name value is outputted as a literal as no closing bracer '}' is detected.