Inserts a substring into a string.
NewString := INSSTR(String, SubString, Position)
- Type: Text constant or code The string into which you want to insert a substring.
- Type: Text constant or code The substring that you want to insert into String.
- Type: Integer Specifies where to insert SubString. Position must be greater than or equal to 1. If Position is greater than the length of String, then the result is concatenated and copied to NewString.
Property Value/Return Value
Type: Text constant or code
The result after SubString is inserted into String.
If SubString is empty, then String is returned unchanged.
If Position is less than 1, an error is returned.
If Position is greater than the length of String, SubString is added at the end of String. For example,
INSSTR("Thomas","AAA",999) returns 'ThomasAAA'.
This example requires that you create the following variables and text constants in the C/AL Globals window.
|Text constant||ENU value|
Press ENTER to continue.
The test string before INSSTR is called:\>%1<
The resulting string after INSSTR is called:\>%1<
Str := Text000; SubString := Text001; MESSAGE(Text002, Str); NewString := INSSTR(Str, SubString, 13); MESSAGE(Text003, NewString);
The first message window displays the following:
The test string before INSSTR is called:
>Press ENTER to continue.<
The second message window displays the following:
The resulting string after INSSTR is called:
>Press ENTER or ESC to continue.<