18. Januar 2008 12:22
18. Januar 2008 12:28
String := 'Stadt,Land,Fluss';
StadtString := copystr(String,1,STRPOS(String,',')-1);
18. Januar 2008 12:41
SELECTSTR (String)
Use this function to retrieve a substring from a comma-separated string.
NewString := SELECTSTR(Number, CommaString)
Number
Data type: integer
This number tells the system 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, a run-time error occurs.
CommaString
Data type: option
A string containing substrings separated by commas.
NewString
Data type: option
The substring that the system retrieves from CommaString.
Comments
SELECTSTR treats string values as OPTIONS. This means that identical values in different strings are not allowed.
Example
This example shows how to use the SELECTSTR function:
CommaStr := Text000;
SubStr1 := SELECTSTR(2, CommaStr); // Pick out the 2nd substring
SubStr2 := SELECTSTR(4, CommaStr); // Pick out the 4th substring
MESSAGE(Text001 + '>%1<\' + '>%2<', SubStr1, SubStr2);
Create the following text constants in the C/AL Globals window:
Text Constant
ENU Value
Text000
'This,is a comma,separated,string'
Text001
'The two calls to SELECTSTR return:\'
The message window will show the following:
The two calls to SELECTSTR return:
>is a comma<
>string<
String := 'Stadt,Land,Fluss';
StadtString := SELECTSTR(1, String);
9. Juni 2008 10:30
9. Juni 2008 10:36
9. Juni 2008 10:41
9. Juni 2008 13:00
Split(String : Text[250];Separator : Text[30];Index : Integer) value : Text[250]
value := String;
pos := STRPOS(value, Separator);
WHILE (pos > 0) AND (Index > 1) DO BEGIN
value := COPYSTR(value, pos+1);
Index -= 1;
pos := STRPOS(value, Separator);
END;
IF pos > 0 THEN
value := COPYSTR(value, 1, pos-1);
EXIT(value);
3. Februar 2010 14:26
Index -= 1;
3. Februar 2010 14:40
Index := Index -1;
3. Februar 2010 14:59
Split(VAR ArryStr : ARRAY [4] OF Text[250];String : Text[250];Separator : Text[30])
value := String;
FOR Index := 1 TO 4 DO BEGIN
pos := STRPOS(value, Separator);
WHILE (pos > 0) AND (Index > 1) DO BEGIN
value := COPYSTR(value, pos+1);
Index -= 1;
pos := STRPOS(value, Separator);
END;
IF pos > 0 THEN BEGIN
value := COPYSTR(value, 1, pos-1);
ArryStr[Index] := value;
end;
end;
Split(VAR ArryStr : ARRAY [4] OF Text[250];String : Text[250];Separator : Text[30])
value := String;
FOR n := 1 TO 4 DO BEGIN
pos := STRPOS(value, Separator);
Index := n;
WHILE (pos > 0) AND (Index > 1) DO BEGIN
value := COPYSTR(value, pos+1);
Index -= 1;
pos := STRPOS(value, Separator);
END;
IF pos > 0 THEN BEGIN
value := COPYSTR(value, 1, pos-1);
ArryStr[n] := value;
end;
end;
3. Februar 2010 15:48
PROCEDURE Splitstr(str : Text[250];SplitChar : Text[1];VAR ResArray : ARRAY [10] OF Text[30]) : Integer
VAR
ai : integer;
BEGIN
CLEAR(ResArray);
ai:=0;
str := DELCHR(str,'>',SplitChar)+SplitChar;
WHILE (STRLEN(str) >0) DO BEGIN
ai +=1;
i := STRPOS(str,SplitChar);
ResArray[ai] := COPYSTR(str,1,i);
str := COPYSTR(str,i+1,250);
END;
EXIT(ai);
END;
3. Februar 2010 16:33
3. Februar 2010 16:57
3. Februar 2010 16:59
Michelle hat geschrieben:SELECTSTR erlaubt den Wert jeweils nur einmal.
3. Februar 2010 17:37
ResArray[ai] := COPYSTR(str,1,i);
ResArray[ai] := COPYSTR(str,1,i - 1);
3. Februar 2010 18:05