SwitchList ( )

Function stats

Average user rating
46
137
9999
Support
FileMaker 8.0 +
Date posted
13 December 2008
Last updated
13 December 2008
Version
Recursive function
No

Author Info
 Agnès

17 functions

Average Rating 4.6

author_avatar



 

Function overview

Prototype

SwitchList  ( ListA;   ListB;   CaseSensitive )


Parameters

ListA  


ListB  


CaseSensitive  Boolean


Description

Tags:  Switch   Remove   List   Add  

To add or remove several values in a list

Be careful, the listB to does not contain duplicate data, only unique data

Examples

Sample input

1/---------------
SwitchList ( "ID_100¶ID_300¶ID_152¶ID_125" ; “ID_250¶ID_300¶ID_125” ; "" or 0 )

2/--------------- With Case Sensitive
SwitchList ( "James¶Alex¶Max¶max¶Anne" ; “max¶James¶Ugo¶Fabrice” ; 1 )


Sample output

1/---------------
"ID_100¶ID_152¶ID_250"
[ add ID_250, remove ID_300 & ID_125]

2/--------------- With Case Sensitive
"Alex¶Max¶Anne¶Ugo¶Fabrice”
[ add Ugo & Fabrice, remove max & James ]

 

Function code

// SwitchList ( ListA ; ListB ; CaseSensitive ) v2.0
// requires CustomList ( start ; End ; Function )

/*
To add or remove several values in a list
CaseSensitive [ Boolean ] : empty or 0 or 1
*/

//---------------------------------- Example
/*
SwitchList ( "ID_100¶ID_300¶ID_152¶ID_125" ; “ID_250¶ID_300¶ID_125” ; "" or 0 )
Result > "ID_100¶ID_152¶ID_250" [ add ID_250, remove ID_300 & ID_125]

CaseSensitive :
SwitchList ( "James¶Alex¶Max¶max¶Anne" ; “max¶James¶Ugo¶Fabrice” ; 1 )
Result > "Alex¶Max¶Anne¶Ugo¶Fabrice” [ add Ugo & Fabrice, remove max & James ]

Be careful, the listB to does not contain duplicate data, only unique data

*/
//------------------------------------------------------------*/
// Agnès Barouh - Juillet 2007 - BugsReport : barouh.agnes@wanadoo.fr
//------------------------------------------------------------*/
Case (

not ( CaseSensitive = 1 or ( GetAsNumber ( CaseSensitive + 0 ) = 0 ) ) ; "Incorrect CaseSensitive" ;

Let ([
$SL_Tag = "|" ;
$SL_MyFirstList = ListA & ¶ & ListB ;
$SL_MyList = "|" & Substitute ( Choose ( CaseSensitive ; Upper ( ListA ) ; ListA ) ; [ ¶ ; "|¶|" ] ) & "|" ;
$SL_Values = Choose ( CaseSensitive ; Upper ( ListB ) ; ListB ) ;

Trigger = CustomList ( 1 ; ValueCount ( $SL_Values ) ;
"Let ([
Value = GetValue ( $SL_Values ; [n] ) ;
$SL_MyList = Substitute ( $SL_MyList ; $SL_Tag & Value & $SL_Tag ; \"X##X\" & Value & $SL_tag ) ;
Test = Substitute ( $SL_MyList ; \"X##X\" & Value & $SL_Tag ; \"####\" ) ] ;
case ( PatternCount ( Test ; \"####\" ) < 1 ; $SL_Tag & Value ; \"X##X\" ) )" ) ;

$SL_MyList = $SL_MyList & ¶ & Trigger
] ;
CustomList ( 1 ; ValueCount ( $SL_MyList ) ;
"Let ([
Value = GetValue ( $SL_MyList ; [n] )];
Case ( PatternCount ( Value ; \"X##X\" ) < 1 ; GetValue ( $SL_MyFirstList ; [n] ) ) )" )
)
& Let([ $SL_MyFirstList = "" ; $SL_MyList = "" ; $SL_Values = ""]; "" ) )

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

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

    Prototype: SwitchList( ListA; ListB; CaseSensitive )
    Function Author: Agnès (http://www.fmfunctions.com/mid/46)
    Last updated: 13 December 2008
    Version: 1.1

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