|
| Workaround with Substitute fucntion and diacritical marks |
 |
Thu, 27 Mar 2008 05:33:46 -070 |
Hello,
I am working on a solution that will highlight the search criteria in
the results layout. However, I have run into a problem. Many searches
include multiple words and to do the highlighting, I use the
Substitute function. The problem I am having is that the solution is
in a foreign language which uses diacritical marks such as (é, í, ó,
etc.) If the user searches for a word but does not include the accent
marks, the substitute function doesn't find it. Since our users,
unfortunately, don't always use the correct spelling with the accents,
the highlighting results don't work properly.
I have been able to do this with single word searches not using the
Substitute function, but I am unable to get it to work with multiples.
Any ideas, please help!
I am using the following Custom Functions below which I found on
briandunning.com site.
Stephen
--------------
FOR SINGLE WORD SEARCHES - THIS WORKS, INCLUDING ACCENT MARKS
--------------
/*
HiliteSingle function
Author
*COMMENT Visual Realisation
Format
HiliteSingle ( text ; searchString ; color )
Parameters
text - any text expression or text field;
searchString - any text expression or text field;
color - any integer number from 0 to 16777215.
Data type returned
text
Description
Returns text with every occurrence of searchString in text changed to
the specified color.
The HiliteSingle() function is NOT case-sensitive. Occurences of
searchString are matched regardless of case, and returned in their
original case.
October 3, 2006
*/
Let ( [
// TEST FOR MATCH
pos = Position ( text ; searchString ; 1 ; 1 )
] ;
// IF MATCH IS FOUND
Case ( pos ;
// BEGIN CALCULATION
Let ( [
textBefore = Left ( text ; pos - 1 ) ;
len = Length ( searchString ) ;
string = Middle ( text ; pos ; len ) ;
textAfter = Right ( text ; Length ( text ) - pos - len + 1 )
] ;
textBefore & TextColor ( string ; color ) & HiliteSingle ( textAfter ;
searchString ; color )
) ;
// ELSE RETURN TEXT
text )
)
--------------
FOR MULTIPLE WORD SEARCHES - THIS WORKS, BUT NOT WITH THE ACCENT MARKS
--------------
/*
HiliteMulti function
Author
*COMMENT Visual Realisation
Format
HiliteMulti ( text ; searchValues ; color )
Parameters
text - any text expression or text field;
searchValues - any text expression or text field;
color - any integer number from 0 to 16777215.
Data type returned
text
Description
Returns text with every occurrence of each value in searchValues in
text changed to the specified color.
The searchValues parameter accepts a list of multiple values,
separated by carriage returns.
Requires the HiliteSingle() custom function.
The HiliteMulti() function is NOT case-sensitive. Occurences of
searchValues are matched regardless of case, and returned in their
original case.
October 3, 2006
*/
Let ( [
searchString = Substitute ( LeftValues ( searchValues ; 1 ) ; ¶ ;
"" ) ;
newText = HiliteSingle ( text; searchString; color )
] ;
Case (
ValueCount ( searchValues ) > 1 ;
HiliteMulti ( newText ; RightValues ( searchValues ; ValueCount
( searchValues ) - 1 ) ; color ) ;
newText
)
|
| Post Reply
|
| Re: Workaround with Substitute fucntion and diacritical marks |
 |
Thu, 27 Mar 2008 06:36:31 -070 |
On Mar 27, 7:19 am, "Remi-Noel Menegaux" <rnmenegaux AT
free.fr>
wrote:
> My way to solve this is to first create a global in which the user puts
its
> criteria.
> Then I create a script in which one step is to Replace into a global (or
> variable) the 'TTBS' = 'Text To Be searched' any 'wrong' character by a
good
> one. Ie it could look like this (pseudo code) :
> Set Field (
> Substitute ( Substitute ( Substitute ( Substitute ( Substitute (
Substitute
> ( Substitute ( Substitute ( Substitute ( Substitute (
> Working_Text; " "; ""); "CR"; "");
"é"; "e")etc..
> ))))))))))
> (where 'CR' stands for 'Carriage Return')
> Then you apply the same formula to the search criteria and you make a
'Find'
> of the modified criteria into the Working Text.
> There are maybe more elegant ways to do that.
> HTH.
One neat feature of the Substitute function eliminates the need for
nested Substitutes, using one sub and optional square brackets. So,
instead you can say Substitute(Working_Text; [" " ; ""];
["CR"; ""];
|
| Post Reply
|
| Re: Workaround with Substitute fucntion and diacritical marks |
 |
Thu, 27 Mar 2008 14:19:46 +010 |
My way to solve this is to first create a global in which the user puts its
criteria.
Then I create a script in which one step is to Replace into a global (or
variable) the 'TTBS' = 'Text To Be searched' any 'wrong' character by a good
one. Ie it could look like this (pseudo code) :
Set Field (
Substitute ( Substitute ( Substitute ( Substitute ( Substitute ( Substitute
( Substitute ( Substitute ( Substitute ( Substitute (
Working_Text; " "; ""); "CR"; "");
"é"; "e")etc..
))))))))))
(where 'CR' stands for 'Carriage Return')
Then you apply the same formula to the search criteria and you make a 'Find'
of the modified criteria into the Working Text.
There are maybe more elegant ways to do that.
HTH.
Remi-Noel
<stephen.wallace@agmd.org> a écrit dans le message de
news:22372181-c993-4737-9604-a3f67e62950c@n75g2000hsh.googlegroups.com...
Hello,
I am working on a solution that will highlight the search criteria in
the results layout. However, I have run into a problem. Many searches
include multiple words and to do the highlighting, I use the
Substitute function. The problem I am having is that the solution is
in a foreign language which uses diacritical marks such as (é, í, ó,
etc.) If the user searches for a word but does not include the accent
marks, the substitute function doesn't find it. Since our users,
unfortunately, don't always use the correct spelling with the accents,
the highlighting results don't work properly.
I have been able to do this with single word searches not using the
Substitute function, but I am unable to get it to work with multiples.
Any ideas, please help!
I am using the following Custom Functions below which I found on
briandunning.com site.
Stephen
--------------
FOR SINGLE WORD SEARCHES - THIS WORKS, INCLUDING ACCENT MARKS
--------------
/*
HiliteSingle function
Author
*COMMENT Visual Realisation
Format
HiliteSingle ( text ; searchString ; color )
Parameters
text - any text expression or text field;
searchString - any text expression or text field;
color - any integer number from 0 to 16777215.
Data type returned
text
Description
Returns text with every occurrence of searchString in text changed to
the specified color.
The HiliteSingle() function is NOT case-sensitive. Occurences of
searchString are matched regardless of case, and returned in their
original case.
October 3, 2006
*/
Let ( [
// TEST FOR MATCH
pos = Position ( text ; searchString ; 1 ; 1 )
] ;
// IF MATCH IS FOUND
Case ( pos ;
// BEGIN CALCULATION
Let ( [
textBefore = Left ( text ; pos - 1 ) ;
len = Length ( searchString ) ;
string = Middle ( text ; pos ; len ) ;
textAfter = Right ( text ; Length ( text ) - pos - len + 1 )
] ;
textBefore & TextColor ( string ; color ) & HiliteSingle ( textAfter ;
searchString ; color )
) ;
// ELSE RETURN TEXT
text )
)
--------------
FOR MULTIPLE WORD SEARCHES - THIS WORKS, BUT NOT WITH THE ACCENT MARKS
--------------
/*
HiliteMulti function
Author
*COMMENT Visual Realisation
Format
HiliteMulti ( text ; searchValues ; color )
Parameters
text - any text expression or text field;
searchValues - any text expression or text field;
color - any integer number from 0 to 16777215.
Data type returned
text
Description
Returns text with every occurrence of each value in searchValues in
text changed to the specified color.
The searchValues parameter accepts a list of multiple values,
separated by carriage returns.
Requires the HiliteSingle() custom function.
The HiliteMulti() function is NOT case-sensitive. Occurences of
searchValues are matched regardless of case, and returned in their
original case.
October 3, 2006
*/
Let ( [
searchString = Substitute ( LeftValues ( searchValues ; 1 ) ; ¶ ;
"" ) ;
newText = HiliteSingle ( text; searchString; color )
] ;
Case (
ValueCount ( searchValues ) > 1 ;
HiliteMulti ( newText ; RightValues ( searchValues ; ValueCount
( searchValues ) - 1 ) ; color ) ;
newText
)
)
|
| Post Reply
|
| Re: Workaround with Substitute fucntion and diacritical marks |
 |
Thu, 27 Mar 2008 15:32:33 -070 |
On Mar 27, 10:19 am, "Remi-Noel Menegaux" <rnmenegaux AT
free.fr>
wrote:
> My way to solve this is to first create a global in which the user puts
its
> criteria.
> Then I create a script in which one step is to Replace into a global (or
> variable) the 'TTBS' = 'Text To Be searched' any 'wrong' character by a
good
> one. Ie it could look like this (pseudo code) :
> Set Field (
> Substitute ( Substitute ( Substitute ( Substitute ( Substitute (
Substitute
> ( Substitute ( Substitute ( Substitute ( Substitute (
> Working_Text; " "; ""); "CR"; "");
"é"; "e")etc..
> ))))))))))
> (where 'CR' stands for 'Carriage Return')
> Then you apply the same formula to the search criteria and you make a
'Find'
> of the modified criteria into the Working Text.
> There are maybe more elegant ways to do that.
> HTH.
> Remi-Noel
>
Thanks for the quick response!
I see how this would work. However, it would also render the actual
text that will be viewed later on without any of the diacritical
markings. It's weird, because when you do a normal search within
FileMaker it will overlook these markings and return both with and
without. I wish the substitute function had an option to modify how it
works.
Any other ideas?
|
| Post Reply
|
| Re: Workaround with Substitute fucntion and diacritical marks |
 |
Thu, 27 Mar 2008 22:24:43 -070 |
On Mar 27, 4:32 pm, stephen.wall...@agmd.org wrote:
> On Mar 27, 10:19 am, "Remi-Noel Menegaux" <rnmenegaux AT
free.fr>
> wrote:
>
> I see how this would work. However, it would also render the actual
> text that will be viewed later on without any of the diacritical
> markings. It's weird, because when you do a normal search within
> FileMaker it will overlook these markings and return both with and
> without. I wish the substitute function had an option to modify how it
> works.
>
I'm not sure what the issue really is. I could not get the
SingleHilite CF to highlight a word with an accented letter if only a
word with the unaccented letter was entered. Are you modifying the
SingleHilite or using it as is? What are the language settings for
the field? Are you using Substitute somewhere other than the
|
| Post Reply
|
|
|