This works for any mix of ucase/lcase in a string ...
Create a Parameter, e.g., {?Search Comment}.
===========
Create a Formula, e.g., "Highlight Part of Text":
===========
Local StringVar Value := {Table.FieldContainingTextToBeSearched};
Local StringVar ValueToSearch := {?SearchComment};
Local StringVar TagStart := "<font color = blue>";
Local StringVar TagEnd := "</font color>";
Local StringVar Output := "";
Local NumberVar StartPosition;
Local NumberVar EndPosition;
Local NumberVar i;
// Search the string and add the tags around the searched value
If Length(ValueToSearch) <> 0 Then
(
While instr(Value,ValueToSearch,1) <> 0 Do
(
// Find the starting position of the word containing the searched value
StartPosition := inStr(Value,ValueToSearch,1);
i := StartPosition;
While i >= 1 Do
(
If Value = ' ' Then
(
StartPosition := i+1;
i := 0;
)
Else If i = 1 Then
(
StartPosition := 1;
i := 0;
)
Else
i := i - 1;
);
// Find the end position of the word containing the searched value
EndPosition := inStr(Value,ValueToSearch,1)+ Length(ValueToSearch)-1;
i := EndPosition;
While i <= Length(Value) Do
(
If Value in [' ','!','?','.',','] Then
(
EndPosition := i-1;
i := Length(Value)+1;
)
Else If i = Length(Value) Then
(
EndPosition := Length(Value);
i := Length(Value)+1;
)
Else
i := i + 1;
);
// Add the tags around the words
Output := Output + (If StartPosition > 1 Then Value[1 to StartPosition - 1]) +
TagStart + Value[StartPosition to EndPosition] + TagEnd;
// String remaining that will be searched to find any occurance of the searched value.
If EndPosition = Length(Value) Then
Value := ""
Else
Value := Value[EndPosition + 1 to Length(Value)];
);
);
// Display the result
Output + Value
Thanks goes to Rahul Singh at Business Objects for this solution!
Helen
===========