String operations in Template Editor

Tekla Structures
2020
Tekla Structures

String operations in Template Editor

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 rule 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".

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.

Was this helpful?
Previous
Next