Function overview
Prototype
Matrix (
MatrixList; SeparatorOrTagXml; KeepEmpty )
Parameters
MatrixList
SeparatorOrTagXml
KeepEmpty
Description
Tags:
Matrix List concatenate
To build a Matrix with several lists
Matrix can be used to concatenate all combinaisons to prepare search
Requires CustomList ( start ; End ; Function )
Not recursive function
---------------------------------- Parameter
MatrixList --> Enter one list or more for build the list
SeparatorOrTagXml --> tag xml for one list, or séparator for more
KeepEmpty --> Boolean and optional : Keep empty list or not
---------------------------------- Usage [Matrix in Matrix]
Matrix ( Matrix ( MatrixList ; SeparatorOrTagXml ; KeepEmpty ) & Matrix ( MatrixList ; SeparatorOrTagXml ; KeepEmpty ) & (...) ; SeparatorOrTagXml ; KeepEmpty )
---------------------------------- Example with 5 lists (with two empty list)
List_A contains "1¶2¶3"
List_B contains "A¶B"
List_C is empty
List_D contains "y¶z"
List_E is empty
1/ all KeepEmpty < 1 : we do not keep empty lists | Principal SeparatorOrTagXml are " | "
Matrix ( Matrix ( List_A ; "" ; "" ) & Matrix ( List_B ; "" ; "" ) & Matrix ( List_C ; "" ; "" ) & Matrix ( List_D ; "" ; "" ) & Matrix ( List_E ; "" ; "" ) ; " | " ; 0 )
Result :
1 | A | y
2 | A | y
3 | A | y
1 | B | y
2 | B | y
3 | B | y
1 | A | z
2 | A | z
3 | A | z
1 | B | z
2 | B | z
3 | B | z
2/ Principal KeepEmpty = 1 : we keep empty lists | Principal SeparatorOrTagXml are " . "
Matrix ( Matrix ( List_A ; "" ; "" ) & Matrix ( List_B ; "" ; "" ) & Matrix ( List_C ; "" ; "" ) & Matrix ( List_D ; "" ; "" ) & Matrix ( List_E ; "" ; "" ) ; " . " ; 1 )
Result :
1 . A . EmptyList . y . EmptyList
2 . A . EmptyList . y . EmptyList
3 . A . EmptyList . y . EmptyList
1 . B . EmptyList . y . EmptyList
2 . B . EmptyList . y . EmptyList
3 . B . EmptyList . y . EmptyList
1 . A . EmptyList . z . EmptyList
2 . A . EmptyList . z . EmptyList
3 . A . EmptyList . z . EmptyList
1 . B . EmptyList . z . EmptyList
2 . B . EmptyList . z . EmptyList
3 . B . EmptyList . z . EmptyList
3/ Principal KeepEmpty = 0 and secondary KeepEmpty are 0 or 1 : we do not keep all empty lists | Principal SeparatorOrTagXml are " "
Matrix ( Matrix ( List_A ; "" ; 1 ) & Matrix ( List_B ; "" ; 1 ) & Matrix ( List_C ; "" ; 1 ) & Matrix ( List_D ; "" ; 1 ) & Matrix ( List_E ; "" ; 0 ) ; " " ; 0 )
Result :
1 A EmptyList y
2 A EmptyList y
3 A EmptyList y
1 B EmptyList y
2 B EmptyList y
3 B EmptyList y
1 A EmptyList z
2 A EmptyList z
3 A EmptyList z
1 B EmptyList z
2 B EmptyList z
3 B EmptyList z
4/ Principal KeepEmpty = 1 : we keep empty lists | Principal SeparatorOrTagXml are " " and secondary SeparatorOrTagXml are Tag for tag Data
Matrix ( Matrix ( List_A ; "L_A" ; "" ) & Matrix ( List_B ; "L_B" ; "" ) & Matrix ( List_C ; "L_C" ; "" ) & Matrix ( List_D ; "L_D" ; "" ) & Matrix ( List_E ; "L_E" ; "" ) ; " " ; 1 )
Result :
<L_A>1</L_A> <L_B>A</L_B> <L_C>EmptyList</L_C> <L_D>y</L_D> <L_E>EmptyList</L_E>
<L_A>2</L_A> <L_B>A</L_B> <L_C>EmptyList</L_C> <L_D>y</L_D> <L_E>EmptyList</L_E>
<L_A>3</L_A> <L_B>A</L_B> <L_C>EmptyList</L_C> <L_D>y</L_D> <L_E>EmptyList</L_E>
<L_A>1</L_A> <L_B>B</L_B> <L_C>EmptyList</L_C> <L_D>y</L_D> <L_E>EmptyList</L_E>
<L_A>2</L_A> <L_B>B</L_B> <L_C>EmptyList</L_C> <L_D>y</L_D> <L_E>EmptyList</L_E>
<L_A>3</L_A> <L_B>B</L_B> <L_C>EmptyList</L_C> <L_D>y</L_D> <L_E>EmptyList</L_E>
<L_A>1</L_A> <L_B>A</L_B> <L_C>EmptyList</L_C> <L_D>z</L_D> <L_E>EmptyList</L_E>
<L_A>2</L_A> <L_B>A</L_B> <L_C>EmptyList</L_C> <L_D>z</L_D> <L_E>EmptyList</L_E>
<L_A>3</L_A> <L_B>A</L_B> <L_C>EmptyList</L_C> <L_D>z</L_D> <L_E>EmptyList</L_E>
<L_A>1</L_A> <L_B>B</L_B> <L_C>EmptyList</L_C> <L_D>z</L_D> <L_E>EmptyList</L_E>
<L_A>2</L_A> <L_B>B</L_B> <L_C>EmptyList</L_C> <L_D>z</L_D> <L_E>EmptyList</L_E>
<L_A>3</L_A> <L_B>B</L_B> <L_C>EmptyList</L_C> <L_D>z</L_D> <L_E>EmptyList</L_E>
5/ All KeepEmpty are empty : we keep empty lists | Principal SeparatorOrTagXml are " | " and secondary SeparatorOrTagXml are Tag for tag Data
Matrix ( Matrix ( List_A ; "L_A" ; "" ) & Matrix ( List_B ; "L_B" ; "" ) & Matrix ( List_C ; "L_C" ; "" ) & Matrix ( List_D ; "L_D" ; "" ) & Matrix ( List_E ; "L_E" ; "" ) ; " | " ; "" )
Result :
<L_A>1</L_A> | <L_B>A</L_B> | <L_D>y</L_D>
<L_A>2</L_A> | <L_B>A</L_B> | <L_D>y</L_D>
<L_A>3</L_A> | <L_B>A</L_B> | <L_D>y</L_D>
<L_A>1</L_A> | <L_B>B</L_B> | <L_D>y</L_D>
<L_A>2</L_A> | <L_B>B</L_B> | <L_D>y</L_D>
<L_A>3</L_A> | <L_B>B</L_B> | <L_D>y</L_D>
<L_A>1</L_A> | <L_B>A</L_B> | <L_D>z</L_D>
<L_A>2</L_A> | <L_B>A</L_B> | <L_D>z</L_D>
<L_A>3</L_A> | <L_B>A</L_B> | <L_D>z</L_D>
<L_A>1</L_A> | <L_B>B</L_B> | <L_D>z</L_D>
<L_A>2</L_A> | <L_B>B</L_B> | <L_D>z</L_D>
<L_A>3</L_A> | <L_B>B</L_B> | <L_D>z</L_D>
Examples
Sample input
1/ --------------------
Matrix ( Matrix ( "Toyota¶Chrysler" ; "" ; "" ) & Matrix ( "Yellow¶Red¶Black" ; "" ; "" ) & Matrix ( "2 doors¶5 doors" ; "" ; "" ) ; " | " ; 0 )
2/ --------------------
Matrix ( Matrix ( "Toyota¶Chrysler" ; "Car" ; "" ) & Matrix ( "Yellow¶Red¶Black" ; "Color" ; "" ) & Matrix ( "2 doors¶5 doors" ; "Door" ; "" ) ; " " ; 0 )
Sample output
1/ --------------------
Toyota | Yellow | 2 doors
Chrysler | Yellow | 2 doors
Toyota | Red | 2 doors
Chrysler | Red | 2 doors
Toyota | Black | 2 doors
Chrysler | Black | 2 doors
Toyota | Yellow | 5 doors
Chrysler | Yellow | 5 doors
Toyota | Red | 5 doors
Chrysler | Red | 5 doors
Toyota | Black | 5 doors
Chrysler | Black | 5 doors
2/ --------------------
<Car>Toyota</Car> <Color>Yellow</Color> <Door>2 doors</Door>
<Car>Chrysler</Car> <Color>Yellow</Color> <Door>2 doors</Door>
<Car>Toyota</Car> <Color>Red</Color> <Door>2 doors</Door>
<Car>Chrysler</Car> <Color>Red</Color> <Door>2 doors</Door>
<Car>Toyota</Car> <Color>Black</Color> <Door>2 doors</Door>
<Car>Chrysler</Car> <Color>Black</Color> <Door>2 doors</Door>
<Car>Toyota</Car> <Color>Yellow</Color> <Door>5 doors</Door>
<Car>Chrysler</Car> <Color>Yellow</Color> <Door>5 doors</Door>
<Car>Toyota</Car> <Color>Red</Color> <Door>5 doors</Door>
<Car>Chrysler</Car> <Color>Red</Color> <Door>5 doors</Door>
<Car>Toyota</Car> <Color>Black</Color> <Door>5 doors</Door>
<Car>Chrysler</Car> <Color>Black</Color> <Door>5 doors</Door>
Function code
// Matrix ( MatrixList ; SeparatorOrTagXml ; KeepEmpty ) v2.0
// requires CustomList ( start ; End ; Function )
/*
Usage :
Matrix ( Matrix ( MatrixList ; SeparatorOrTagXml ; KeepEmpty ) & Matrix ( MatrixList ; SeparatorOrTagXml ; KeepEmpty ) & (...) ; SeparatorOrTagXml ; KeepEmpty )
*/
/*
To build a Matrix with several lists
Matrix can be used to concatenate all combinaisons to prepare search
*/
//---------------------------------- Parameter
// MatrixList --> Enter one list or more
// SeparatorOrTagXml --> tag xml for one list, or séparator for more
// KeepEmpty --> Boolean and optional : Keep empty list or not
//---------------------------------- Example with 5 lists (with two empty list)
/*
List_A contains "1¶2¶3"
List_B contains "A¶B"
List_C is empty
List_D contains "y¶z"
List_E is empty
1/ all KeepEmpty < 1 : we do not keep empty lists | Principal SeparatorOrTagXml are " | "
Matrix ( Matrix ( List_A ; "" ; "" ) & Matrix ( List_B ; "" ; "" ) & Matrix ( List_C ; "" ; "" ) & Matrix ( List_D ; "" ; "" ) & Matrix ( List_E ; "" ; "" ) ; " | " ; 0 )
Result :
1 | A | y
2 | A | y
3 | A | y
1 | B | y
2 | B | y
3 | B | y
1 | A | z
2 | A | z
3 | A | z
1 | B | z
2 | B | z
3 | B | z
2/ Principal KeepEmpty = 1 : we keep empty lists | Principal SeparatorOrTagXml are " . "
Matrix ( Matrix ( List_A ; "" ; "" ) & Matrix ( List_B ; "" ; "" ) & Matrix ( List_C ; "" ; "" ) & Matrix ( List_D ; "" ; "" ) & Matrix ( List_E ; "" ; "" ) ; " . " ; 1 )
Result :
1 . A . EmptyList . y . EmptyList
2 . A . EmptyList . y . EmptyList
3 . A . EmptyList . y . EmptyList
1 . B . EmptyList . y . EmptyList
2 . B . EmptyList . y . EmptyList
3 . B . EmptyList . y . EmptyList
1 . A . EmptyList . z . EmptyList
2 . A . EmptyList . z . EmptyList
3 . A . EmptyList . z . EmptyList
1 . B . EmptyList . z . EmptyList
2 . B . EmptyList . z . EmptyList
3 . B . EmptyList . z . EmptyList
3/ Principal KeepEmpty = 0 and secondary KeepEmpty are 0 or 1 : we do not keep all empty lists | Principal SeparatorOrTagXml are " "
Matrix ( Matrix ( List_A ; "" ; 1 ) & Matrix ( List_B ; "" ; 1 ) & Matrix ( List_C ; "" ; 1 ) & Matrix ( List_D ; "" ; 1 ) & Matrix ( List_E ; "" ; 0 ) ; " " ; 0 )
Result :
1 A EmptyList y
2 A EmptyList y
3 A EmptyList y
1 B EmptyList y
2 B EmptyList y
3 B EmptyList y
1 A EmptyList z
2 A EmptyList z
3 A EmptyList z
1 B EmptyList z
2 B EmptyList z
3 B EmptyList z
4/ Principal KeepEmpty = 1 : we keep empty lists | Principal SeparatorOrTagXml are " " and secondary SeparatorOrTagXml are Tag for tag Data
Matrix ( Matrix ( List_A ; "L_A" ; "" ) & Matrix ( List_B ; "L_B" ; "" ) & Matrix ( List_C ; "L_C" ; "" ) & Matrix ( List_D ; "L_D" ; "" ) & Matrix ( List_E ; "L_E" ; "" ) ; " " ; 1 )
Result :
<L_A>1</L_A> <L_B>A</L_B> <L_C>EmptyList</L_C> <L_D>y</L_D> <L_E>EmptyList</L_E>
<L_A>2</L_A> <L_B>A</L_B> <L_C>EmptyList</L_C> <L_D>y</L_D> <L_E>EmptyList</L_E>
<L_A>3</L_A> <L_B>A</L_B> <L_C>EmptyList</L_C> <L_D>y</L_D> <L_E>EmptyList</L_E>
<L_A>1</L_A> <L_B>B</L_B> <L_C>EmptyList</L_C> <L_D>y</L_D> <L_E>EmptyList</L_E>
<L_A>2</L_A> <L_B>B</L_B> <L_C>EmptyList</L_C> <L_D>y</L_D> <L_E>EmptyList</L_E>
<L_A>3</L_A> <L_B>B</L_B> <L_C>EmptyList</L_C> <L_D>y</L_D> <L_E>EmptyList</L_E>
<L_A>1</L_A> <L_B>A</L_B> <L_C>EmptyList</L_C> <L_D>z</L_D> <L_E>EmptyList</L_E>
<L_A>2</L_A> <L_B>A</L_B> <L_C>EmptyList</L_C> <L_D>z</L_D> <L_E>EmptyList</L_E>
<L_A>3</L_A> <L_B>A</L_B> <L_C>EmptyList</L_C> <L_D>z</L_D> <L_E>EmptyList</L_E>
<L_A>1</L_A> <L_B>B</L_B> <L_C>EmptyList</L_C> <L_D>z</L_D> <L_E>EmptyList</L_E>
<L_A>2</L_A> <L_B>B</L_B> <L_C>EmptyList</L_C> <L_D>z</L_D> <L_E>EmptyList</L_E>
<L_A>3</L_A> <L_B>B</L_B> <L_C>EmptyList</L_C> <L_D>z</L_D> <L_E>EmptyList</L_E>
5/ All KeepEmpty are empty : we keep empty lists | Principal SeparatorOrTagXml are " | " and secondary SeparatorOrTagXml are Tag for tag Data
Matrix ( Matrix ( List_A ; "L_A" ; "" ) & Matrix ( List_B ; "L_B" ; "" ) & Matrix ( List_C ; "L_C" ; "" ) & Matrix ( List_D ; "L_D" ; "" ) & Matrix ( List_E ; "L_E" ; "" ) ; " | " ; "" )
Result :
<L_A>1</L_A> | <L_B>A</L_B> | <L_D>y</L_D>
<L_A>2</L_A> | <L_B>A</L_B> | <L_D>y</L_D>
<L_A>3</L_A> | <L_B>A</L_B> | <L_D>y</L_D>
<L_A>1</L_A> | <L_B>B</L_B> | <L_D>y</L_D>
<L_A>2</L_A> | <L_B>B</L_B> | <L_D>y</L_D>
<L_A>3</L_A> | <L_B>B</L_B> | <L_D>y</L_D>
<L_A>1</L_A> | <L_B>A</L_B> | <L_D>z</L_D>
<L_A>2</L_A> | <L_B>A</L_B> | <L_D>z</L_D>
<L_A>3</L_A> | <L_B>A</L_B> | <L_D>z</L_D>
<L_A>1</L_A> | <L_B>B</L_B> | <L_D>z</L_D>
<L_A>2</L_A> | <L_B>B</L_B> | <L_D>z</L_D>
<L_A>3</L_A> | <L_B>B</L_B> | <L_D>z</L_D>
*/
//----------------------------------
// @ Agnès. December, 2008 BugReport - barouh.agnes@wanadoo.fr
//----------------------------------
Case (
//================================= Part One - Buid one List
not PatternCount ( MatrixList ; "EndListMatrix" ) ;
Let ([
Nettoyage = Substitute ( "#^#" & MatrixList & "#^#" ;
[ ¶ & "#^#" ; "" ] ; [ ¶ ; "¶#^#" ]; [ "#^#¶"; "" ]; [ "¶#^#"; ¶ ]; [ "¶#^#"; "" ]; [ "#^#"; "" ] ) ;
$MX_Passe = $MX_Passe + 1 ;
TagL = "§#§" & $MX_Passe & "§#§" & "<" & SeparatorOrTagXml & ">" ;
TagR = "</" & SeparatorOrTagXml & ">"
];
Case (
IsEmpty ( Nettoyage ) ;
TagL & "EmptyList" & Choose ( KeepEmpty ; "" ; "§#§" ) & TagR ;
TagL & Substitute ( Nettoyage ; [ ¶ ; TagR & ¶ & TagL ] ) & TagR
) & "<EndListMatrix>" )
;
//================================= Part Two - Build The List with all "first list"
not IsEmpty ( MatrixList ) ;
Let ([
cfMx = "<EndListMatrix>" ;
$MX_rc = ¶ ; $MX_num = 0 ; $MX_Passe = 0 ; $MX_sum = 0 ; $MX_x = 1 ; $MX_Count = 0 ; $MX_M = "" ; $MX_n = "" ;
$MX_Keep = KeepEmpty ;
$MX_GetV = Substitute ( MatrixList & "#^#" ; [ cfMx & "#^#" ; "" ] ; [ ¶ ; "^§|§^" ] ; [ cfMx ; ¶ ] ; [ "#^#"; "" ] ) ;
Charge = CustomList ( 1 ; ValueCount ( $MX_GetV ) ; "Let ([
Value = Substitute ( GetValue ( $MX_GetV ; [n] ) ; \"^§|§^\" ; $MX_rc ) ;
Test = PatternCount ( Value ; \">EmptyList<\" ) ;
Result = Case ( ( $MX_Keep <> 1 And Test <> 1 ) or $MX_Keep = 1 ; Let ([
$MX_num = $MX_num + 1 ;
$MX_MxVar[$MX_num] = Value ;
$MX_sum = $MX_sum + ValueCount ( $MX_MxVar[$MX_num] ) ;
$MX_n = $MX_n & Case ( not IsEmpty ( $MX_n ) ; $MX_rc ) & [n] ]; GetValue ( $MX_MxVar[$MX_num] ; 1 ) ) ) ]; Result )" ) ;
$MX_First = Substitute ( Charge ; $MX_rc ; SeparatorOrTagXml ) ;
Result = CustomList ( 1 ; $MX_sum ; "Let ([
Variable = $MX_MxVar[$MX_x] ;
$MX_Count = Case ( $MX_Count = ValueCount ( Variable ) ; 1 ; $MX_Count + 1 ) ;
Value = GetValue ( Variable ; 1 ) ;
Test = $MX_Count = 1 And [n] > 1 ;
$MX_M = Choose ( Test ; $MX_M & Case ( not IsEmpty ( $MX_M ) ; $MX_rc ) & Substitute ( $MX_First ; Value ; GetValue ( Variable ; $MX_Count ) ) ; $MX_First ) ;
$MX_x = $MX_x + Test ;
$MX_First = Case ( $MX_Count = ValueCount ( $MX_MxVar[$MX_x] ) ; Substitute ( $MX_M ; [ \"§#§\" & GetValue ( $MX_n ; $MX_x ) & \"§#§\" ; \"\" ] ) ; $MX_First )];\"\" )" )
];
Substitute ( $MX_First ; [ "<>" ; "" ] ; [ "</>" ; "" ] ; [ "EmptyList§#§" ; "EmptyList" ] )
)
)
// ===================================
/*
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/171
Prototype: Matrix( MatrixList; SeparatorOrTagXml; KeepEmpty )
Function Author: Agnès (http://www.fmfunctions.com/mid/46)
Last updated: 26 December 2008
Version: 1.4
*/
// ===================================
// Matrix ( MatrixList ; SeparatorOrTagXml ; KeepEmpty ) v2.0__LITBR__// requires CustomList ( start ; End ; Function )__LITBR____LITBR__/*__LITBR__Usage : __LITBR__Matrix ( Matrix ( MatrixList ; SeparatorOrTagXml ; KeepEmpty ) & Matrix ( MatrixList ; SeparatorOrTagXml ; KeepEmpty ) & (...) ; SeparatorOrTagXml ; KeepEmpty )__LITBR__*/__LITBR__ /*__LITBR__ To build a Matrix with several lists__LITBR__ Matrix can be used to concatenate all combinaisons to prepare search__LITBR__ */__LITBR____LITBR__//---------------------------------- Parameter__LITBR__// MatrixList --> Enter one list or more__LITBR__// SeparatorOrTagXml --> tag xml for one list, or séparator for more__LITBR__// KeepEmpty --> Boolean and optional : Keep empty list or not__LITBR____LITBR__//---------------------------------- Example with 5 lists (with two empty list)__LITBR__/*__LITBR__List_A contains "1¶2¶3" __LITBR__List_B contains "A¶B" __LITBR__List_C is empty __LITBR__List_D contains "y¶z" __LITBR__List_E is empty__LITBR____LITBR__1/ all KeepEmpty < 1 : we do not keep empty lists | Principal SeparatorOrTagXml are " | "__LITBR__Matrix ( Matrix ( List_A ; "" ; "" ) & Matrix ( List_B ; "" ; "" ) & Matrix ( List_C ; "" ; "" ) & Matrix ( List_D ; "" ; "" ) & Matrix ( List_E ; "" ; "" ) ; " | " ; 0 )__LITBR____LITBR__Result :__LITBR__1 | A | y__LITBR__2 | A | y__LITBR__3 | A | y__LITBR__1 | B | y__LITBR__2 | B | y__LITBR__3 | B | y__LITBR__1 | A | z__LITBR__2 | A | z__LITBR__3 | A | z__LITBR__1 | B | z__LITBR__2 | B | z__LITBR__3 | B | z__LITBR____LITBR__2/ Principal KeepEmpty = 1 : we keep empty lists | Principal SeparatorOrTagXml are " . "__LITBR__Matrix ( Matrix ( List_A ; "" ; "" ) & Matrix ( List_B ; "" ; "" ) & Matrix ( List_C ; "" ; "" ) & Matrix ( List_D ; "" ; "" ) & Matrix ( List_E ; "" ; "" ) ; " . " ; 1 )__LITBR____LITBR__Result :__LITBR__1 . A . EmptyList . y . EmptyList__LITBR__2 . A . EmptyList . y . EmptyList__LITBR__3 . A . EmptyList . y . EmptyList__LITBR__1 . B . EmptyList . y . EmptyList__LITBR__2 . B . EmptyList . y . EmptyList__LITBR__3 . B . EmptyList . y . EmptyList__LITBR__1 . A . EmptyList . z . EmptyList__LITBR__2 . A . EmptyList . z . EmptyList__LITBR__3 . A . EmptyList . z . EmptyList__LITBR__1 . B . EmptyList . z . EmptyList__LITBR__2 . B . EmptyList . z . EmptyList__LITBR__3 . B . EmptyList . z . EmptyList__LITBR____LITBR__3/ Principal KeepEmpty = 0 and secondary KeepEmpty are 0 or 1 : we do not keep all empty lists | Principal SeparatorOrTagXml are " "__LITBR__Matrix ( Matrix ( List_A ; "" ; 1 ) & Matrix ( List_B ; "" ; 1 ) & Matrix ( List_C ; "" ; 1 ) & Matrix ( List_D ; "" ; 1 ) & Matrix ( List_E ; "" ; 0 ) ; " " ; 0 )__LITBR____LITBR__Result :__LITBR__1 A EmptyList y__LITBR__2 A EmptyList y__LITBR__3 A EmptyList y__LITBR__1 B EmptyList y__LITBR__2 B EmptyList y__LITBR__3 B EmptyList y__LITBR__1 A EmptyList z__LITBR__2 A EmptyList z__LITBR__3 A EmptyList z__LITBR__1 B EmptyList z__LITBR__2 B EmptyList z__LITBR__3 B EmptyList z__LITBR____LITBR__4/ Principal KeepEmpty = 1 : we keep empty lists | Principal SeparatorOrTagXml are " " and secondary SeparatorOrTagXml are Tag for tag Data__LITBR__Matrix ( Matrix ( List_A ; "L_A" ; "" ) & Matrix ( List_B ; "L_B" ; "" ) & Matrix ( List_C ; "L_C" ; "" ) & Matrix ( List_D ; "L_D" ; "" ) & Matrix ( List_E ; "L_E" ; "" ) ; " " ; 1 )__LITBR____LITBR__Result :__LITBR__<L_A>1</L_A> <L_B>A</L_B> <L_C>EmptyList</L_C> <L_D>y</L_D> <L_E>EmptyList</L_E>__LITBR__<L_A>2</L_A> <L_B>A</L_B> <L_C>EmptyList</L_C> <L_D>y</L_D> <L_E>EmptyList</L_E>__LITBR__<L_A>3</L_A> <L_B>A</L_B> <L_C>EmptyList</L_C> <L_D>y</L_D> <L_E>EmptyList</L_E>__LITBR__<L_A>1</L_A> <L_B>B</L_B> <L_C>EmptyList</L_C> <L_D>y</L_D> <L_E>EmptyList</L_E>__LITBR__<L_A>2</L_A> <L_B>B</L_B> <L_C>EmptyList</L_C> <L_D>y</L_D> <L_E>EmptyList</L_E>__LITBR__<L_A>3</L_A> <L_B>B</L_B> <L_C>EmptyList</L_C> <L_D>y</L_D> <L_E>EmptyList</L_E>__LITBR__<L_A>1</L_A> <L_B>A</L_B> <L_C>EmptyList</L_C> <L_D>z</L_D> <L_E>EmptyList</L_E>__LITBR__<L_A>2</L_A> <L_B>A</L_B> <L_C>EmptyList</L_C> <L_D>z</L_D> <L_E>EmptyList</L_E>__LITBR__<L_A>3</L_A> <L_B>A</L_B> <L_C>EmptyList</L_C> <L_D>z</L_D> <L_E>EmptyList</L_E>__LITBR__<L_A>1</L_A> <L_B>B</L_B> <L_C>EmptyList</L_C> <L_D>z</L_D> <L_E>EmptyList</L_E>__LITBR__<L_A>2</L_A> <L_B>B</L_B> <L_C>EmptyList</L_C> <L_D>z</L_D> <L_E>EmptyList</L_E>__LITBR__<L_A>3</L_A> <L_B>B</L_B> <L_C>EmptyList</L_C> <L_D>z</L_D> <L_E>EmptyList</L_E>__LITBR____LITBR__5/ All KeepEmpty are empty : we keep empty lists | Principal SeparatorOrTagXml are " | " and secondary SeparatorOrTagXml are Tag for tag Data__LITBR__Matrix ( Matrix ( List_A ; "L_A" ; "" ) & Matrix ( List_B ; "L_B" ; "" ) & Matrix ( List_C ; "L_C" ; "" ) & Matrix ( List_D ; "L_D" ; "" ) & Matrix ( List_E ; "L_E" ; "" ) ; " | " ; "" )__LITBR____LITBR__Result :__LITBR__<L_A>1</L_A> | <L_B>A</L_B> | <L_D>y</L_D>__LITBR__<L_A>2</L_A> | <L_B>A</L_B> | <L_D>y</L_D>__LITBR__<L_A>3</L_A> | <L_B>A</L_B> | <L_D>y</L_D>__LITBR__<L_A>1</L_A> | <L_B>B</L_B> | <L_D>y</L_D>__LITBR__<L_A>2</L_A> | <L_B>B</L_B> | <L_D>y</L_D>__LITBR__<L_A>3</L_A> | <L_B>B</L_B> | <L_D>y</L_D>__LITBR__<L_A>1</L_A> | <L_B>A</L_B> | <L_D>z</L_D>__LITBR__<L_A>2</L_A> | <L_B>A</L_B> | <L_D>z</L_D>__LITBR__<L_A>3</L_A> | <L_B>A</L_B> | <L_D>z</L_D>__LITBR__<L_A>1</L_A> | <L_B>B</L_B> | <L_D>z</L_D>__LITBR__<L_A>2</L_A> | <L_B>B</L_B> | <L_D>z</L_D>__LITBR__<L_A>3</L_A> | <L_B>B</L_B> | <L_D>z</L_D>__LITBR____LITBR__*/__LITBR__//----------------------------------__LITBR__// @ Agnès. December, 2008 BugReport - barouh.agnes@wanadoo.fr__LITBR__//----------------------------------__LITBR____LITBR____LITBR__Case (__LITBR____LITBR__//================================= Part One - Buid one List__LITBR__not PatternCount ( MatrixList ; "EndListMatrix" ) ;__LITBR____LITBR__Let ([__LITBR____LITBR__ Nettoyage = Substitute ( "#^#" & MatrixList & "#^#" ; __LITBR__ [ ¶ & "#^#" ; "" ] ; [ ¶ ; "¶#^#" ]; [ "#^#¶"; "" ]; [ "¶#^#"; ¶ ]; [ "¶#^#"; "" ]; [ "#^#"; "" ] ) ;__LITBR__ $MX_Passe = $MX_Passe + 1 ;__LITBR__ TagL = "§#§" & $MX_Passe & "§#§" & "<" & SeparatorOrTagXml & ">" ;__LITBR__ TagR = "</" & SeparatorOrTagXml & ">" __LITBR__];__LITBR__Case ( __LITBR__IsEmpty ( Nettoyage ) ; __LITBR__TagL & "EmptyList" & Choose ( KeepEmpty ; "" ; "§#§" ) & TagR ;__LITBR__TagL & Substitute ( Nettoyage ; [ ¶ ; TagR & ¶ & TagL ] ) & TagR __LITBR__) & "<EndListMatrix>" )__LITBR__;__LITBR__//================================= Part Two - Build The List with all "first list"__LITBR__not IsEmpty ( MatrixList ) ;__LITBR____LITBR__Let ([__LITBR____LITBR__ cfMx = "<EndListMatrix>" ;__LITBR__ $MX_rc = ¶ ; $MX_num = 0 ; $MX_Passe = 0 ; $MX_sum = 0 ; $MX_x = 1 ; $MX_Count = 0 ; $MX_M = "" ; $MX_n = "" ;__LITBR__ $MX_Keep = KeepEmpty ;__LITBR____LITBR__ $MX_GetV = Substitute ( MatrixList & "#^#" ; [ cfMx & "#^#" ; "" ] ; [ ¶ ; "^§|§^" ] ; [ cfMx ; ¶ ] ; [ "#^#"; "" ] ) ;__LITBR____LITBR__ Charge = CustomList ( 1 ; ValueCount ( $MX_GetV ) ; "Let ([ __LITBR__Value = Substitute ( GetValue ( $MX_GetV ; [n] ) ; \"^§|§^\" ; $MX_rc ) ;__LITBR__Test = PatternCount ( Value ; \">EmptyList<\" ) ;__LITBR__Result = Case ( ( $MX_Keep <> 1 And Test <> 1 ) or $MX_Keep = 1 ; Let ([ __LITBR__$MX_num = $MX_num + 1 ;__LITBR__$MX_MxVar[$MX_num] = Value ;__LITBR__$MX_sum = $MX_sum + ValueCount ( $MX_MxVar[$MX_num] ) ;__LITBR__$MX_n = $MX_n & Case ( not IsEmpty ( $MX_n ) ; $MX_rc ) & [n] ]; GetValue ( $MX_MxVar[$MX_num] ; 1 ) ) ) ]; Result )" ) ;__LITBR____LITBR__ $MX_First = Substitute ( Charge ; $MX_rc ; SeparatorOrTagXml ) ;__LITBR____LITBR__ Result = CustomList ( 1 ; $MX_sum ; "Let ([__LITBR__Variable = $MX_MxVar[$MX_x] ;__LITBR__$MX_Count = Case ( $MX_Count = ValueCount ( Variable ) ; 1 ; $MX_Count + 1 ) ;__LITBR__Value = GetValue ( Variable ; 1 ) ;__LITBR__Test = $MX_Count = 1 And [n] > 1 ;__LITBR__$MX_M = Choose ( Test ; $MX_M & Case ( not IsEmpty ( $MX_M ) ; $MX_rc ) & Substitute ( $MX_First ; Value ; GetValue ( Variable ; $MX_Count ) ) ; $MX_First ) ;__LITBR__$MX_x = $MX_x + Test ;__LITBR__$MX_First = Case ( $MX_Count = ValueCount ( $MX_MxVar[$MX_x] ) ; Substitute ( $MX_M ; [ \"§#§\" & GetValue ( $MX_n ; $MX_x ) & \"§#§\" ; \"\" ] ) ; $MX_First )];\"\" )" ) __LITBR__];__LITBR__ Substitute ( $MX_First ; [ "<>" ; "" ] ; [ "</>" ; "" ] ; [ "EmptyList§#§" ; "EmptyList" ] )__LITBR__)__LITBR__)__LITBR____LITBR__// ===================================__LITBR__/*__LITBR____LITBR__ This function is published on FileMaker Custom Functions__LITBR__ to check for updates and provide feedback and bug reports__LITBR__ please visit http://www.fmfunctions.com/fid/171__LITBR____LITBR__ Prototype: Matrix( MatrixList; SeparatorOrTagXml; KeepEmpty )__LITBR__ Function Author: Agnès (http://www.fmfunctions.com/mid/46)__LITBR__ Last updated: 26 December 2008__LITBR__ Version: 1.4__LITBR____LITBR__*/__LITBR__// ===================================
Login or register to comment
Create a new account with fmcustomfunctions.com or login to post a comment.