Language Reference Guide : System Classes : StringObject Class : SubString Method
 
Share this page          
SubString Method
The SubString method returns a section of the StringObject, starting at startposition and extending length characters, into a varchar variable.
This method has the following syntax:
varchar = StringObject.SubString([startposition = integer]
          [, length = integer])
This method has the following parameters:
startposition
Specifies the starting position of the substring
Default: 1
length
Specifies the length of the substring in characters
Default: end of the string
In a StringObject, the characters are numbered from left to right, starting with number one. If the start position is less than one, the value of it is set to one. If startposition plus length exceeds the length of the string, the method returns the end of the StringObject, starting at the value of startposition.
This method provides one way to move an entire StringObject into a varchar variable. An alternative method is to use the Value attribute, as in:
varcharvar = strobj.Value;
Whether you use the SubString method or the Value attribute, if the string object is larger than the declared size of the varchar variable, it is truncated silently. The limitation of the varchar is 32K in non-UTF8 and 16K in UTF8.