I have the need to merge two arrays that both share the same structure and use numeric keys . I have a solution but wonder if there is a more efficient way of achieving the same result?
Code: Select all
on mouseUp pMouseButton
--combine two arrays
local tArrayA
Local tArrayB
Local tArrayC
put "Cat" into tArrayA[2]["Species"]
put "Dog" into tArrayA[4]["Species"]
put "Mouse" into tArrayA[6]["Species"]
put "Lion" into tArrayA[8]["Species"]
put "Big" into tArrayA[8]["Size"]
put "Wolf" into tArrayA[5]["Species"]
put "Rose" into tArrayB[1]["Species"]
put "Mallow" into tArrayB[2]["Species"]
put "Wheat" into tArrayB[3]["Species"]
put "Rape" into tArrayB[4]["Species"]
put "Beetroot" into tArrayB[5]["Species"]
put 0 into tCount
repeat for each key tKey in tArrayA
add 1 to tCount
put tArrayA[tKey] into tArrayC[tCount]
end repeat
repeat for each key tKey in tArrayB
add 1 to tCount
put tArrayB[tKey] into tArrayC[tCount]
end repeat
end mouseUp