On 8/19/22 15:07, Bob Sneidar via use-livecode wrote:
Off the top of my head:

split v1 by tab
split v2 by tab
split v3 by tab
split v4 by tab

put the keys of v1 into tKeyList
sort tKeyList ascending numeric

repeat for each line tKey in tKeyList
    put tKey & tab & v1 [tKey] & tab & v2 [tKey] & tab & v3 [tKey] & tab & v4 
[tKey] & cr after tCombined
end repeat

Not sure if this will be faster, but every time you refer to a line of a string 
the engine has to parse out where that line is from the beginning.

It is indeed faster. Here's what I came up with. I'm not sure why 2000 lines of text in four fields should take that long, I came up with

original code: 320 ms
array version: 21 ms

   put empty into vCombined
   put fld "A" into v1
   put fld "B" into v2
   put fld "C" into v3
   put fld "D" into v4
   split v1 by cr
   split v2 by cr
   split v3 by cr
   split v4 by cr
   put 1 into i
   repeat for each element tLine in v1
      put i&tab&v1[i]&tab&v2[i]&tab&v3[i]&tab&v4[i]&tab&cr after vCombined
      add 1 to i
   end repeat

 Mark Wieder

use-livecode mailing list
Please visit this url to subscribe, unsubscribe and manage your subscription 

Reply via email to