Επεξεργασία

Κοινή χρήση μέσω


Text.DelStr(Text, Integer [, Integer]) Method

Version: Available or changed with runtime version 1.0.

Deletes a substring inside a string (text or code).

Syntax

NewString :=   Text.DelStr(String: Text, Position: Integer [, Length: Integer])

Note

This method can be invoked without specifying the data type name.

Parameters

String
 Type: Text
The input string.

Position
 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.

[Optional] Length
 Type: Integer
Specifies how many characters to delete. Length must be greater than zero (0).

Return Value

NewString
 Type: Text
The input string without the specified substring.

Remarks

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.

Example

var
    Str: Text[40];
    NewStr: Text[40];
    Position: Integer;
    Length: Integer;
    Text000: TexConst ENU='Adjusting prices - Please wait.';
    Text001: TexConst ENU='The original string:>%1<';
    Text002: TexConst ENU='The original modified:>%2<';
begin
    Str := Text000;  
    Position := 11; // Remove the word 'prices' and a blank.  
    Length := 7;  
    NewStr := DelStr(Str, Position, Length);  
    Message(Text001, Str);  
    Message(Text002, NewStr);  
end;

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.<

Text Data Type
Get Started with AL
Developing Extensions