TextHighlightWithStyles ( )

Function stats

Average user rating
5.0000
37
268
9999
Support
FileMaker 8.0 +
Date posted
06 September 2010
Last updated
15 January 2011
Version
Recursive function
Yes

Author Info
 Fabrice

74 functions

Average Rating 4.4

author_avatar



 

Function overview

Prototype

TextHighlightWithStyles  ( _text;   _searchString;   _styles )


Parameters

_text  the text to display


_searchString  the string to highlight


_styles  styles separated by +. See documentation.


Description

Tags:  Text Parsing   Text   Interface   Format  

g :
TextHighlightWithStyles ( "Kennedy was assassinated, like his brother KENNEDY" ; "Kennedy" ; bold+italic )

Will highlight both occurrences of 'Kennedy' by adding bold and italic syles.

Not Case Sensitive
Recursive

This function is handy to display the result of Quickfind, especially with HighlightYellow.

For a list of available styles, check this page :
http://www.filemaker.com/11help/html/func_ref3.33.99.html#1032591

Examples

Sample input

TextHighlightWithStyles ( "Kennedy was assassinated, like his brother KENNEDY" ; "Kennedy" ; bold+italic )


Sample output

Will highlight both occurrences of 'Kennedy' by adding bold and italic sytles.

 

Function code

/*TextHighlightWithStyles ( _text ; _searchString ; _styles )

by Fabrice Nordmann, 1-more-thing
v.1.1 Sept 2010
v.1 March 2010


Highlights a string found in a text by adding one or more styles

eg :
TextHighlightWithStyles ( "Kennedy was assassinated, like his brother KENNEDY" ; "Kennedy" ; bold+italic )

Will highlight both occurrences of 'Kennedy' by adding bold and italic styles.

Not Case Sensitive
Recursive


This function is handy to display the result of Quickfind, especially with HighlightYellow.

For a list of available styles, check this page :
http://www.filemaker.com/11help/html/func_ref3.33.99.html#1032591

*/

Let ([
    _pos = Position ( _text ; _searchString ; 1 ; 1 ) ;
    _len = Length ( _searchString )
];
    Case ( PatternCount ( _text ; _searchString ) ;
        Left ( _text ; _pos -1 ) & TextStyleAdd ( Middle ( _text ; _pos ; _len ) ; _styles ) & TextHighlightWithStyles ( Right ( _text ; Length ( _text ) - _pos - _len + 1 ) ; _searchString ; _styles ) ;
        _text
    )
)


// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/268

    Prototype: TextHighlightWithStyles( _text; _searchString; _styles )
    Function Author: Fabrice (http://www.fmfunctions.com/mid/37)
    Last updated: 15 January 2011
    Version: 1.2

*/
// ===================================

 

Comments

trlewis
07 September 2010



I'm new at using Custom Functions. When I try to create this one, FM tells me ti can find Fin function. Searching has not provided me any additional info. Where can I find the custom function Fin?
  General comment
Fabrice
07 September 2010



Hi,

sorry, was a translation error. Now fixed (Fin is the French translation of Right)
  General comment
Genx
01 December 2010



Awesome!!
  General comment

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (31)
Date  (28)
XML  (26)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (12)
Layout Objects  (11)
Filter  (11)
Design  (10)
Array  (7)