Deletes a substring inside a string (text or code).
NewString := DELSTR(String, Position[, Length])
- Type: Text constant or code The input string.
- Type: Integer The position of the first character that you want to delete. Position must be greater than zero (0). If Position exceeds the length of String, DELSTR returns the original string, unchanged.
- Type: Integer Specifies how many characters to delete. Length must be greater than zero (0).
Property Value/Return Value
Type: Text constant or code
The resulting string.
If you omit Length, all the characters starting with Position are deleted until the end of the string.
If you omit Length and Position is less than 1, then an error is returned.
If you omit Length and Position is greater than the length of String, then String is returned unchanged.
This example requires that you create the following variables and text constants in the C/AL Globals window.
|Text constant||ENU value|
Adjusting prices - Please wait.
The original string:\>%1<
The modified string:\>%2<
Str := Text000; Position := 11; // Remove the word 'prices' and a blank. Length := 7; NewStr := DELSTR(Str, Position, Length); MESSAGE(Text001, Str); MESSAGE(Text002, NewStr);
The first message window displays the following:
The original string:
>Adjusting prices - Please wait.<
The second message window displays the following:
The modified string:
>Adjusting - Please wait.<