SELECTSTR ERROR
kirkostas
Member Posts: 127
Hi,
I am using the SYSTEM String function SELECTSTR to split a Comma Separated string.
Error message:
'STRSET' cannot contain 'Kostas' more than once.
Why?
I want to split this string into an array. How?
I am using the SYSTEM String function SELECTSTR to split a Comma Separated string.
CommaStr := 'Kostas,Tassos,Kostas'; MyStr := SELECTSTR(2,CommaStr);This code produce an error.
Error message:
'STRSET' cannot contain 'Kostas' more than once.
Why?
I want to split this string into an array. How?
kirkostas™
0
Comments
-
Hi,
..because it using the string as an option string so it need a unique code per option.
It wouldn't be hard to code this yourself0 -
Damn !!! ](*,)
Ok thanks for the quick answer.
I will use some code
eventually. kirkostas™0 -
This function is called Distinct_Values. It takes a comma separated string, check for duplicate values and removes them. I use SELECTSTR function but I add a custom number at the end of each string before pass it to Distinct_Values function since it works like an Option string.
For example:Distinct_Values('Kostas'+'1,'+'Tassos'+'2,'+'Kostas'+'3');//Split Values FOR i := 1 TO 3 DO BEGIN Arr1[i] := SELECTSTR(i,CommaString); Arr1[i] := COPYSTR(Arr1[i],1,STRLEN(Arr1[i])-1); END; //Collect Distinct Values FOR i := 1 TO 3 DO BEGIN Found := FALSE; tmp_check := Arr1[i]; FOR z := 1 TO 3 DO BEGIN IF Arr2[z] = tmp_check THEN BEGIN IF NOT Found THEN Found := TRUE; END; END; Added :=FALSE; IF NOT Found THEN BEGIN FOR z := 1 TO 3 DO BEGIN IF Arr2[z] = '' THEN BEGIN IF NOT Added THEN BEGIN Arr2[z] := tmp_check; Added := TRUE; END; END; END; END; END; //Add Distinct Values FOR i := 1 TO 3 DO IF Arr2[i] <> '' THEN RelativeDocs := RelativeDocs + Arr2[i] + ' '; //Trim RelativeDocs := DELCHR(RelativeDocs,'<>',' ');
Variables:
Arr1 Code 30 (3 Dimensions)
Arr2 Code 30 (3 Dimensions)
tmp_check Code 30
Found Boolean
Added Boolean
z Integer
i Integer
Parameters:
CommaString Text 100
You can change whatever you want, you can have 500 Dimensions and bigger text strings if you like.
You can make it return comma separated text if you like too.
The code just drops the empty strings and collect only the ones with a value and which are not duplicated.kirkostas™0 -
Wow that didn't take you long - well done
0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions