Compare text in single string

Dean_Axon
Member Posts: 193
can anyone point me in the direction of how to compare text inside a single string.
What I need to achieve is if the same wording appears more than once in the same string I then need to be able to shorten that string by taking the replication of the word out.
i.e.
'the cold weather is cold'
Shorten to :
'the cold weather is '
Any ideas ??
What I need to achieve is if the same wording appears more than once in the same string I then need to be able to shorten that string by taking the replication of the word out.
i.e.
'the cold weather is cold'
Shorten to :
'the cold weather is '
Any ideas ??
Remember: Keep it simple
0
Comments
-
The may not be the clean but it was fun to do. This relies on a space being between the words. The bottom loop is just a garbage loop to give the answer.
Create a form with the following variables. Create a push button and place the code in the onpush trigger. You will also need to create two text boxes. One with a source of CurString the other with a source of AnswerString.
I Integer
X Integer
NumOfWords Integer
WordArray Text 200
CurString Text 200
AnswerString Text 200
Blank Text 1
MakeWord Text 200
CompareWord Text 200
FoundOne Boolean
I := 0;
X := 0;
REPEAT
I += 1;
IF FORMAT(CurString) <> ' ' THEN BEGIN
MakeWord := MakeWord + FORMAT(CurString);
END ELSE BEGIN
X += 1;
WordArray[X] := MakeWord + ' ';
MakeWord := '';
END;
UNTIL I = STRLEN(CurString);
I := X;
NumOfWords := X;
X := 0;
REPEAT
REPEAT
X += 1;
IF (WordArray = WordArray[X]) AND NOT (X = I) THEN
WordArray := '';
UNTIL X = NumOfWords;
X := 0;
I -= 1;
UNTIL I = 0;
COMPRESSARRAY(WordArray);
X := 0;
REPEAT
X += 1;
AnswerString := AnswerString + WordArray[X];
UNTIL X = 100;
CurrForm.UPDATE;0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions