Page 2 of 2

Re: Enhanced "combine" command

Posted: Sat Sep 30, 2017 8:25 am
by Thierry
SparkOut wrote:Thierry once told me I should respect him because he is older than me. (Not sure by how much but it can't be that many years.)
Sparkout, I am really that old as I don't remember me saying that :)
I respect practically everybody. I admire Thierry.
Lol, please don't.
I only have a long background with these things,
but I'm still unable to make a complex, beautiful and responsive (scalable) UI for iOS, for instance.

Anyway, if you pass by Paris one of these days, give a ring and we could meet for
a beer ( coffee for me) and we could compare our ID cards :)

Kind regards,

Thierry

Re: Enhanced "combine" command

Posted: Mon Oct 02, 2017 8:37 am
by Thierry
Hi all,

back with a quick solution to do the reverse:

from a flatArray, build the array.

Code: Select all

function buildArrayfromFlatOne T, d1, d2
   local A,  X
   set the itemdel to d1
   repeat for each item L in T
      set the itemdel to d2
      put the number of items of L into n
      put format( "put %s into A",  item n of L ) after X
      repeat with i= 1 to n-1
         put "[" &quote& item i of L &quote& "]" after X 
      end repeat
      put cr after X
   set the itemdel to d1
   end repeat
   do X
   return A
end buildArrayfromFlatOne
and run it:

Code: Select all

   local myArray
   put buildArrayfromFlatOne( fld "flatArray", return, " - " ) into myArray
and test both functions:

Code: Select all

   local myArray
   put buildArrayfromFlatOne( fld "flatArray", return, " - " ) into myArray
   get flattenArray( myArray, return , " - ") 
   
   -- test if original flatArray and new one are the same
   sort IT
   put IT into fld "flatArray2"
   if IT is (the text of fld "flatArray") then get "Good, back with same values :)"
   else get  "Sorry, do your homework :("
   answer IT
Happy coding :)

Thierry