TEMPLATE$ returns a string value containing formatted values and lines of text
TEMPLATE$(Template$, ReplaceMode%=0,1,2, [InpVar])
Arguments
A counter can be included using #&# in the template. Counting starts with 1. Example "#&# ) Woord, #&#) Polyestre, #&#) Foam" returns "1) Wood, 2) Polyester, 3) Foam"
Instead of integer counters, you can use english words (first to tenth) by using "%" instead of "&". For independent counters (same mechanism as counters above applies).
Mode%=0
Assume LPP=33.37 with the cell width in de knowledge base defined as 6
TEMPLATE$("Length between PP: ~LPP [m]", 0, LPP)
Steps taken bij Quaestor:
Remove ~LPP:
Write value "33.37 " from position ~ :
Result:
In this case, insufficient spaces are left in the template between ~LPP and [m].
Mode%=1
To obtain a better result, you can used the ReplaceMode%=1:
TEMPLATE$("Length between PP: ~LPP [m]", 1, LPP)
Steps taken bij Quaestor:
Overwrite ~LPP with spaces:
Write value "33.37 " from position ~:
Result:
Note that 33.37 is followed by a space causing the left bracket to disappear...
Mode%=2
The final option is to use ReplaceMode%=2:
TEMPLATE$("Length between PP: ~LPP [m]", 2, LPP)
Steps taken bij Quaestor:
Remove ~LPP:
Insert value "33.37 " from position ~: Result:
"Length between PP: 33.37 [m]"
Whether to use ReplaceMode%=0,1 or 2 depends on the purpose, the length of the parameter names, the definition of Cell width in the Slot & Properties and the format definition of the values in the template. All options have their advantages and disadvantages....
Assume an object GEOM to contain the following data:
relation:
returns:
Values of RADIUS and THICKNESS are formatted according to the properties in the knowledge base, so fixed format with two decimals placed right in a cell of 9 spaces.
relation:
returns:
Assume with the cell width in de knowledge base defined as 6
TEMPLATE$("Length between PP: #LPP# [m]", 0, LPP)
Steps taken bij Quaestor:
Result:
Assume with the cell width in de knowledge base defined as 6
TEMPLATE$("Length between PP: #LPP|E8.3# [m]", 0, LPP)
Result:
TEMPLATE$("The model will be fitted with#NPROP=2[1]# two propellers and[1]#NPROP=1[1]# one propeller and[1] all appendages", 0, NPROP)
NPROP will be determined by Queastor because it is a parameter in this relation (InpVar).
This relation returns for :
and returns for :
And for ,
is returned.
In this example for both bolean actions the same label [1] is used. In "Text to be placed" further labels and nested logical constructs are allowed. However, Please note that [Label] in nested constructs should be different from [Label] of the surrounding construct. Using following numbers to label parts is a very convenient way.
TEMPLATE$("The model will be fitted with#NPROP>0[1]##NPROP=2[2]# two propellers and[2]#NPROP=1[2]# one propeller and[2][1] all appendages", 0, NPROP)
This relation will give the same result as the previous example but now with a nested expression for NPROP.
Integer values can also be printed as words, however, only for 0-10:
TEMPLATE$("#NPROP|I2&English# propeller#NPROP><1[1]#s[1] fitted.", 0, NPROP)
Returns for
respectively:
For
is returned
A counter can be included in Template$ by "#&#", for example
returns for Option=0:
and for Option=1:
Instead of integer counters, you can use english words first-tenth by using "%" instead of "&". For independent counters, the same principle is applied as above.
TEMPLATE$("#%#) Wood, #%%#) Polyester and #%%%#) Foam", 0)
returns:
You see that Wood, Polyester and Foam all start with first because they all have independent counters...
Simply seperated by comma's and/or spaces is described per line of the following part of an existing input template:
Line 1:
Write as a string of one position (A1) followed by 2 spaces (X2),
the same applies for Line 2:Write as an integer value in a cell of 18 positions (I18) followed by two spaces (X2),
Write as a string of one position
Write as an integer value in a cell of 4 positions (I4)
Write as integer value in a cell of 4 positions followed by a Carriage return Linefeed ( CrLf ) as indicated by "/|" after the format.
Line 3:
Write element 1 in object as integer in a cell of 18 positions followed by two spaces (X2).
If object OWPOL is not present in the solution there are two options:
The data slot of OWPOL contains a @DBDEFAULT, e.g.: :0 (IT IS FOR OBJECTS ONLY ALLOWED TO USE ")" as DBDEFAULT)
In that case, all OWPOL formats are presenting a value of 0.
If in a format OWPOL(NT|I18|X2|1) OWPOL exists and NT does neither exist in OWPOL nor in the level(s) above, the @DBDEFAULT value of NT is printed if available or the message:
"NT has no DBDEFAULT"
Idem Line 4:
Write in E format using 11 decimals in a cell of 18 length (E18.11), followed by two spaces (X2).
Idem for , and . is fourth value from |M4| so write CrLf.
Line 5:
write 6 subsequent values of OWPOL(KQPC) with an E18.11 format followed by two spaces (X2), each time when the line counter |M4| reaches 4, a CrLf is written. If OWPOL contains 4 instead of the indicated 6 values, the 5th and 6th values are given the value zero.
Idem
Idem , expect 30 cases in table OWDAT, if it contains fewer values, write missing values as 0.
After the 30 values, write a CrLf as indicated by "/|"
A parameter being part of a TeliTab cannot be written as ~ParName|Format. In that case it should be either:
Assuming a TeLiTab value of Obj$ of:
returns:
Of the first line: "2nd thickness " is not included in the result because additional, non formatted string information is omitted when you use this definition, so only
is returned, being:
(including a CrLf)
The second line returns
in which 21.00 is a trimmed F6.2 of 21
The third line includes an error message:
because the total string
is viewed as the value to be formatted F6.1
The last line returns
The value 9.1 is the FF2 formatted value from which decimal closing zero's are trimmed.
An object can be treated like a TeLiTab.
if DATA is an object containing:
Then relation:
returns:
The third case of A is taken followed by the content for B in the object. For both parameter no format decription is used (so the format of the Workbase/Slots & Properties is taken).
You can use format tags in the script:
returns:
The third case of A is taken without any format decription (so the format of the Workbase/Slots & Properties is taken). this is followed by the content for B in the object using a Cell width of 12 and 3 decimal places.
Please note, when you use format statement for paramters in the object, you have to close with a CrLf, thus "/|". otherwise all values will be placed behind each other:
returns:
By placing expressions between brackets, you can first perform calculation of which the result will be placed:
and will first be used to calculate the average draught.
or
returns for:
COMPANY$= "Qnowledge"
STREET$="Haagsteeg 2"
CITY$="Wageningen"
The expression "STREET$ + CHR$(13) + CHR$(10) + SPACE$(15) + CITY$" is surrounded by "#" and terminated by "|".
Quick links: Functions overview | Attribute overview | Constants overview | Dimensions overview