Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Version: Available or changed with runtime version 1.0.
Retrieves a substring from this instance.
Syntax
Substring := Text.Substring(StartIndex: Integer [, Count: Integer])
Note
This method can be invoked without specifying the data type name.
Parameters
Text
Type: Text
An instance of the Text data type.
StartIndex
Type: Integer
The one-based starting character position of a substring in this instance.
[Optional] Count
Type: Integer
The number of characters in the substring.
Return Value
Substring
Type: Text
The substring extracted from this instance.
Remarks
Starting with Business Central application version 27.1, the platform supports a Count parameter that exceeds the length of the input text. In application version 27.0 and earlier, the following code raises a runtime error Index and length must refer to a location within the string. (Parameter 'length'):
NewString := '12345'.Substring(1, 10);
In this example, the input text '12345' has a length of 5, but the Count value is 10, which exceeds the string length. If you're targeting application version 27.0 or earlier, use CopyStr instead of Substring.