Text.CopyStr(Text, Integer [, Integer]) Method
Version: Available or changed with runtime version 1.0.
Copies a substring of any length from a specific position in a string (text or code) to a new string.
Syntax
NewString := Text.CopyStr(String: Text, Position: Integer [, Length: Integer])
Note
This method can be invoked without specifying the data type name.
Parameters
String
Type: Text
The string that you want to copy from.
Position
Type: Integer
The position of the first character to copy. If the value of Position is less than 1, then the COPYSTR function returns an error. If Position is greater than the length of the string, then the COPYSTR function returns an empty string.
[Optional] Length
Type: Integer
The number of characters to copy. If the value of Length is less than 0, then the COPYSTR function returns an error. If the value of Length causes Position + Length to be > (total length of the string), then the result includes all the characters from Position to the end of the string. If you omit Length, then the resulting string includes all the characters from Position to the end of the string.
Return Value
NewString
Type: Text
The copied string.
Remarks
If Position combined with Length exceeds the length of the string, all the characters from Position to the end of the string are returned.
Example
var
Str: Text[30];
Position: Integer;
Length: Integer;
NewStr: Text[30];
Text000: Label 'Using the CopyStr method';
Text001: Label 'The original string is:>%1<';
Text002: Label 'The copied string is:>%1<';
begin
Str := Text000;
Position := 7;
Length := 8;
Message(Text001, Str);
NewStr := CopyStr(Str, Position, Length);
Message(Text002, NewStr);
end;
The first message window shows the original string:
The original string is:
>Using the CopyStr method<
The second message window shows the copied string:
The copied string is:
>the COPY<
See Also
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기