Imagine you have a property that contains a data string, and you need to extract a section of the data into a new property.
How do you do it without having to manually enter the data into the new property?
It can be done by using the Substring function of the PLANTDEFINECALCPROPERTIES command:
So for example, you have a 6 digit property called TagCode for hand valves that includes a text prefix followed by a hyphen and then a number (eg, AA-101) and you would like to extract the number (101) into a new property without including the text prefix.
This can be achieved using the following syntax "Substring(TagCode,3,3)":
The resulting calculated property, is a new property, called TagAnno that only includes the last 3 digits from the TagCode property:
May I emphasise that this only works where the position of the 3 digits is fixed.
It is not possible to return the last 3 digits of a variable length string as there is no function available to determine the length of the string.
Thanks for commenting Peter.
The example shown was specifically for extracting the last 3 characters from a 6 character long property.
If the property contains more or less characters then the syntax will of course need to be modified accordingly.
I hate to be pedantic, but this is programming and details matter.
Your calculated property does not always include the last 3 characters of the TagCode. It contains 3 chars starting with the 4th digit. 3 means the 4th char not the 3rd because you use a 0 to get the first char. I don’t know this for sure, but it looks like it based on your example.
If your strings are always 6 characters long, it works out the same. If your strings are 7 characters or longer, it won’t give you the last 3.