Enhanced "combine" command

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 583
Joined: Wed Nov 22, 2006 3:42 pm
Location: France
Contact:

Re: Enhanced "combine" command

Post by Thierry » Sat Sep 30, 2017 8:25 am

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
Thierry Douez - https://sunny-tdz.com
Pourquoi tant de notes lorsqu'il suffit de jouer les plus belles... [Barbara]

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 583
Joined: Wed Nov 22, 2006 3:42 pm
Location: France
Contact:

Re: Enhanced "combine" command

Post by Thierry » Mon Oct 02, 2017 8:37 am

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
Thierry Douez - https://sunny-tdz.com
Pourquoi tant de notes lorsqu'il suffit de jouer les plus belles... [Barbara]

Post Reply

Return to “Feature Requests”