Retrieves a substring from a comma-separated string.
|
NewString := SELECTSTR(Number, CommaString)
|
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: Option
A string containing substrings separated by commas. The maximum
length of this string is 391 characters.
Property Value/Return Value
Type: Option
The substring that is retrieved from CommaString.
Remarks
Example
This example requires that you create the following
variables and text constants in the C/AL Globals window.
Variable name |
DataType |
Subtype |
CommaStr
|
Text
|
60
|
CommaStr2
|
Text
|
60
|
SubStr1
|
Text
|
60
|
SubStr2
|
Text
|
60
|
SubStr3
|
Text
|
60
|
SubStr4
|
Text
|
60
|
Text constant |
ENU value |
Text000
|
This,is a comma,separated,string
|
Text001
|
The calls to SELECTSTR return:\
|
Text002
|
11,22,33,,55,,,
|
|
Copy Code |
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);
|
The message window displays the following text:
The calls to SELECTSTR return:
>is a comma<
>string<
>11<
>33<
This example requires that you create the following
variables and text constants in the C/AL Globals window.
Variable name |
DataType |
Subtype |
CommaStr2
|
Text
|
60
|
SubStr5
|
Text
|
60
|
Text constant |
ENU value |
Text002
|
11,22,33,,55,,,
|
|
Copy Code |
CommaStr2 := Text002;
SubStr5 := SELECTSTR(6,CommaStr2);
MESSAGE('>%1<\', SubStr5);
|
This example returns an error.
See Also