Value :: subString - Extract substring
The function returns a sub-string from the text area for the value handle, beginning at position passed in iStartPosition (first character in text has position 0 ) . When the value handle refers to a non-text data type, the value is converted into string before.
In order to get sub-strings relative to the end of the string, a negative value may be passed in iStartPosition , which calculates the position from the end of the string. When the negative position results in a position outside the string area, the function returns an empty string, except iLength has been set to 0 .
In order to get the remaining part of a string (e.g. the last 20 characters), the start position is set to a negative value (-20) and length is set to 0.
When the length passed in iLength exceeds the string length, the the remaining part of the string from the defined position is returned. When passing 0 for iLength , also the remaining length for the string is used. Passing a negative value for iLength will truncate the string at the end by iLength characters.
When no instance is selected or when the start position is behind the end of data, the function throws an exception.
string ts = "0123456789";
ts.subString(0,4); // returns "0123"
ts.subString(4,4); // returns "4567"
ts.subString(4,0); // returns "456789" remaining part
ts.subString(0,-2); // returns "4567"
ts.subString(-3,2); // returns "56"
ts.subString(-3,0); // returns "56789"
ts.subString(-3,-2);// returns "567"
Implementation details
- iStartPosition
- Start position in string
The start position begins with 0 at the beginning of the string area.
- iLength
- Length
The length is the size allocated for an instance or area.