Ugo Di Luca- EasySort calculation - HELP DECIPHERING PLEASE

Discussion created by ian.moree on Mar 25, 2012
Latest reply on Mar 25, 2012 by sporobolus

Hey Everyone;


Genius moment again by Ugo Di Luca many years ago. I am confused deciphering what the heck is going on here.

I have attached his sample file i found over @ http://www.filemakerhacks.com/?p=1389.


I have started to look @ his calculation and am confused about a few things here. Also in his file, he has a script that looks like this:



@parameters being passed are confusing to me but here they are:



1: 03Name

2. 14AnyNum

3. 25AnyDate

//Script name: Sort

Set Field: Middle(Get ( ScriptParameter ); 1+Choose (Sort::gScriptParameter= Left(Get ( ScriptParameter );1);0;1);1) //DONT UNDERSTAND THIS EITHER

Sort Records

Go to Record/Request :[First]



Let ( [


VL = "Header"; // Name of my Value List is Header



L = ValueListItems ( Get ( FileName ) ;VL); //grab the Value ListItems from "Header"



X = PatternCount( L;"¶") +1; // in Result above, find WHY ADD 1 +1 starts @ 1 so we need ot add 1 to account for that?



N = 1 + Mod (X +Sort::gScriptParameter; X); // if the result of 1 + X + Scriptparameter is divisible by self put result in N



E = MiddleWords( L; N; 1); // look in L and our starting wors is result above, then get the numberofWords( Result of X) = in my case 10



T = MiddleWords(FieldType (Get ( FileName ) ;E);2;1); // Get next word in list i am thinking here



P = Sort::gScriptParameter; // our scriptparameter ( global field)



G = GetField(E) //Get the field type in E




L & ¶ &

Choose( P > 2; // Test the condition if P > 2, the perform results below

Case( // If

T="Number"; // This isNumber

Right( "00000000"& G; 8); //Why do we need to Concat G here ?




T= "Number";

1 / (G + 2); // why do this condition?

T="Date";Date(12;12;3000) - G; // Why minus G

T="Hour"; Time( 23; 59; 59) - G;


Substitute( Upper(G); // ok Genius moment. Make list opposite if asc, des,etc - JKEWL. Seems to me that this Substitute function every master developer LOVES!! - I am thinking i need to learn to master this one..

["A"; "z"];

["B"; "y"];

["C"; "x"];

["D"; "w"];

["E"; "v"];

["F"; "u"];

["G"; "t"];

["H"; "s"];

["I"; "r"];

["J"; "q"];

["K"; "p"];

["L"; "o"];

["M"; "n"];

["N"; "m"];

["O"; "l"];

["P"; "k"];

["Q"; "j"];

["R"; "i"];

["S"; "h"];

["T"; "g"];

["U"; "f"];

["V"; "e"];

["W"; "d"];

["X"; "c"];

["Y"; "b"];

["Z"; "a"] ) )))