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 ??
Remember: Keep it simple
0
Comments
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;