GetReduxList ( )

Function stats

Average user rating
496
380
9999
Support
FileMaker 10.0 +
Date posted
16 April 2015
Last updated
16 April 2015
Version
Recursive function
Yes

Author Info
 Cristos L-C

7 functions

Average Rating None

author_avatar



 

Function overview

Prototype

GetReduxList  ( text;   isBreakOnWords;   minSearchChars;   maxSearchChars )


Parameters

text  The text which you want to turn into a redux list


isBreakOnWords  Should individual words also be broken into substrings? 1 for


minSearchChars  The minimum length string at which to begin searching (e.g., set this to


maxSearchChars  The maximum length string to break out.


Description

Tags:  substring   Search String  

Breaks a piece of text down into its constituent strings, for use in a partial-string match portal search feature. For more information on this search technique, see http://www.mindfiresolutions.com/Filter-portal-records-by-partial-matching-of-search-criteria-in-FileMaker-1022.php

Examples

Sample input

GetReduxList ( "Alpha-Bravo-Charlie" ; 1 ; "3" ; "100" )


Sample output

Alpha-Bravo-Charlie
Alpha-Bravo-Charli
Alpha-Bravo-Charl
Alpha-Bravo-Char
Alpha-Bravo-Cha
Alpha-Bravo-Ch
Alpha-Bravo-C
Alpha-Bravo-
Alpha-Bravo
Alpha-Brav
Alpha-Bra
Alpha-Br
Alpha-B
Alpha-
Alpha
Alph
Alp
Bravo-Charlie
Bravo-Charli
Bravo-Charl
Bravo-Char
Bravo-Cha
Bravo-Ch
Bravo-C
Bravo-
Bravo
Brav
Bra
Charlie
Charli
Charl
Char
Cha

 

Function code

/*
GetReduxList ( text ; isBreakOnWords ; minSearchChars ; maxSearchChars )

DESCRIPTION:
    Explodes a piece of text into its constituent strings, for use in a partial-string match portal search feature.
    For more information on this search technique, see http://www.mindfiresolutions.com/Filter-portal-records-by-partial-matching-of-search-criteria-in-FileMaker-1022.php

PARAMETERS:
    text : REQUIRED
        The text which you want to turn into a redux list
    isBreakOnWords : optional
        Should individual words also be broken into substrings? 1 for "True", 0 for "False"
        Defaults to false ("0").
    minSearchChars : optional
        The minimum length string at which to begin searching (e.g., set this to "3" if you want to start searching after the user types the third character)
        Defaults to 3.
    maxSearchChars : optional
        The maximum length string to break out.
        Defaults to 100.

EXAMPLE:
    GetReduxList ( "Alpha-Bravo-Charlie" ; 0 ; "" ; "" )

RETURNS:
    Alpha-Bravo-Charlie
    Alpha-Bravo-Charli
    Alpha-Bravo-Charl
    ...
    Alpha-B
    Alpha-
    Alpha
    Alph
    Alp

EXAMPLE:
    GetReduxList ( "Alpha-Bravo-Charlie" ; 1 ; "" ; "" )

RETURNS:
    Alpha-Bravo-Charlie
    Alpha-Bravo-Charli
    Alpha-Bravo-Charl
    ...
    Alp
    Bravo-Charlie
    Bravo-Charli
    Bravo-Charl
    ...
    Bravo-C
    Bravo-
    Bravo
    Brav
    Bra
    Charlie
    Charli
    Charl
    Char
    Cha


CHANGELOG:
    v2.1 - 2015-04-15 16:13 EST [cristos@inresonance.com]
        - minor adjustments to display original text in cases where original text is longer than maxSearchChars
    v2.0 - 2015-04-15 11:44 EST [cristos@inresonance.com]
        - added several features (flag to break on words, maximum character length) and slightly refactored for efficiency
    v1.0 - 2015-04-14 16:14 EST [cristos@inresonance.com]
        - created initial function
*/


Let ([

/***********************
    DECLARE VARIABLES
************************/
    null = Case ( 0 ; "null" )
;    ~isBreakOnWords =
        Case (
            /* Accept both "1" and "true" (case insensitive) as truthy. */
            GetAsNumber ( Filter ( isBreakOnWords ; "1234567890" ) ) = 1 ; 1;
            Position ( Lower ( isBreakOnWords ) ; "true" ; 0 ; 1 ) > 0 ; 1;
            /* ELSE */
            0 /* Defaults to false */
        )
;    ~minLength = GetAsNumber ( Case ( IsEmpty ( Filter ( minSearchChars ; "1234567890" ) ) ; 3 ; minSearchChars ) ) /* Defaults to 3 characters */
;    ~maxLength = GetAsNumber ( Case ( IsEmpty ( Filter ( maxSearchChars ; "1234567890" ) ) ; 9 ; maxSearchChars ) ) /* Defaults to 9 characters */

;    ~originalText = text
;    ~trimmedText = Left ( ~originalText ; ~maxLength ) //restrict the word to the maximum search length
;    ~explodedText =
        Case (
            /* IF the text is shorter or equal to the minimum length, just give us the text. */
            Length ( ~trimmedText ) ≤ ~minLength ;
                ~trimmedText & ¶;
            /* ELSE IF the text is longer than the minimum length, give us the text and make a recursive call to get the next substring. */
            Length ( ~trimmedText ) > ~minLength ;
             Let ([
                 ~subText = Left ( ~trimmedText ; Length ( ~trimmedText ) - 1 )
             ];
                 ~trimmedText & ¶ & GetReduxList( ~subText ; 0 ; ~minLength ; ~maxLength )
             )
    )

];

/***********************
    WRITE OUTPUT
***********************/
    Case ( Length ( ~originalText ) > ~maxLength ; ~originalText & ¶ ) /* Also make sure an exact match will work, no matter how long the original text is. */
    & ~explodedText
    & Case (
        WordCount ( ~trimmedText ) > 1 and ~isBreakOnWords;
            Let ([
                ~subWords = RightWords ( ~trimmedText ; WordCount ( ~trimmedText ) - 1 )
            ];
                GetReduxList( ~subWords ; ~isBreakOnWords ; ~minLength ; ~maxLength )
            )
    )
)

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

    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/380

    Prototype: GetReduxList( text; isBreakOnWords; minSearchChars; maxSearchChars )
    Function Author: Cristos L-C (http://www.fmfunctions.com/mid/496)
    Last updated: 16 April 2015
    Version: 1.1

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

 

 

 

 

 

 

 

Top Tags

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