Skip to main content

String operations in Template Editor

Modified: 21 Apr 2023 Tekla Structures 2023
2023
Tekla Structures

String operations are used to convert a text string to something new and are mostly used in value field rules. They cannot operate directly with attributes or value fields; instead, they accept attribute functions and value field functions as parameters.

You can access string functions in the Formula Contents dialog box and in the Rule Contents dialog box. Select functions from the String list in the Operators area of the dialog box.

Before you get started ensure that the Data type is set to Text in the Value Field Properties dialog box.

find

This function returns the offset of a substring in a string.

Parameters: string, substring

For example:

The result equals 2.

match

This function checks if the given two strings are the same and returns TRUE if they are, FALSE if they are not.

For example, match("abc", "abc")=TRUE and match("abc","b")=FALSE.

Parameters: string1, string2

The following formula uses the match function to check if the field value contains a "-" character.

You can also use the wildcard characters ? and * in formulas, for example, match ("aabc", "*b*")=TRUE

mid

This function returns n characters from a string, starting from the position that is given with the offset parameter. If n is omitted, all succeeding characters are returned.

Parameters: string, offset, n

This example returns two characters from the string starting from the second character. The result is "bc".

length

This function returns the number of characters in a string.

Parameter: string

This example returns the number of characters in a string. The result is 4.

reverse

Use this operator to return the mirror image of the string.

Parameter: string

The following example prints "alket" in a report.

getat

This function returns the character in a given offset.

Parameters: string, offset

The following rule calculates the offset of the characters H, E and A, essentially filtering and searching for PROFILEs that begin with HEA.

setat

Use this function to replace a character with another character at the given offset.

Parameters: string, offset, character

The following formula replaces "a" with "b" at the specified offset of 0. The result is "baa".

replace

This function replaces all specified substrings with another string.

Parameters: source string, old substring, new substring

For example:

This returns a string in which all of the space characters from the value returned by GetValue("PROFILE") have been removed.

toupper

This function changes parameter string to all uppercase and returns the string.

Parameter: string

For example:

This returns the value of the NAME-attribute of the part in all uppercase letters, for example, COLUMN.

tolower

This function changes parameter string to all lowercase and returns the string.

Parameter: string

For example:

This returns the value of the NAME-attribute of the part in all lowercase letters, for example, column.

fvf

Use this function to find a value in an external file.

Parameters: filename, key value of row, column number

Where the format for reading files is:

fvf("filename", "key_value_of_row", column_number)

The function gets the value 16 for the profile MET-202Z25 from the Overlap.dat file.

newline

This function inserts a new line in a formula. You can either select it from the list or add it manually by typing \n.

NOTE: This function is only available for value field formulas.

For example:

The result would be:

Width: 100

Height: 27

join

This function joins a list of strings separated with a separator into one string and trims away the empty strings.

Parameter: Separator

Fro example:

If the CopyField functions return the values 7, 7, <nothing>, 10, the result is 7;7;10.

<nothing> in this example means that the HOLE_6 value field is not output because its row is stepped over based on the row rule.

join2

This function joins a list of strings separated with a separator into one string and retains the empty strings.

Parameter: Separator

Fore example:

If the CopyField functions return the values 7, 7, <nothing>, 10, the result is 7;7;;10.

<nothing> in this example means that the HOLE_6 value field is not output because its row is stepped over based on the row rule.

asc

This function returns a character code or an integer code, depending on how it is input.

Parameter: string, integer

If the parameter is a string it returns an integer representing the character code to the first letter in a string.

If the parameter is an integer, it returns characters representing the integer code.

Submit

Table of Contents