Text.SelectStr(Integer, Text) Method
Version: Available or changed with runtime version 1.0.
Retrieves a substring from a comma-separated string.
Syntax
NewString := Text.SelectStr(Number: Integer, CommaString: Text)
Note
This method can be invoked without specifying the data type name.
Parameters
Number
Type: Integer
Specifies which substring to retrieve. The substrings in the comma-separated string are numbered 1, 2, 3, and so on. If Number is greater than the actual number of substrings, then a run-time error occurs.
CommaString
Type: Text
A string that contains substrings separated by commas. The maximum length of this string is 391 characters.
Return Value
NewString
Type: Text
The substring from the comma-separated string at the index specified.
Remarks
SelectStr treats string values as OPTIONS. This means that identical values in different strings are not allowed.
Any trailing commas are removed before the operation starts.
If Number is less than 1 or greater than the number of real values (excluding trailing commas) in the string, then an error is returned.
Quotes are not supported. For example, a,b,"c,d",e is treated as a five-element substring where substring 4 is d".
Example 1
var
CommaStr: Text[60];
CommaStr2: Text[60];
SubStr1: Text[60];
SubStr2: Text[60];
SubStr3: Text[60];
SubStr4: Text[60];
Text000: Label 'This,is a comma,separated,string';
Text001: Label 'The calls to SelectStr return:\\';
Text002: Label '11,22,33,,55,,,';
begin
CommaStr := Text000;
CommaStr2 := Text002;
SubStr1 := SelectStr(2, CommaStr); // Pick out the 2nd substring.
SubStr2 := SelectStr(4, CommaStr); // Pick out the 4th substring.
SubStr3 := SelectStr(1, CommaStr2);
SubStr4 := SelectStr(3, CommaStr2);
Message(Text001 + '>%1<\' + '>%2<\' + '>%3<\' + '>%4<\', SubStr1, SubStr2, SubStr3, SubStr4);
end;
The message window displays the following text:
The calls to SelectStr return:
>is a comma<
>string<
>11<
>33<
Example 2
var
CommaStr2: Text[60];
SubStr5: Text[60];
Text002: Label '11,22,33,,55,,,';
begin
CommaStr2 := Text002;
SubStr5 := SelectStr(6,CommaStr2);
Message('>%1<\', SubStr5);
end;
This example returns an error.
See Also
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기