|
listStepper
This is a parent script which you can feed a list of
lists of arbitrary length and then when you increment
its counter it will return the nth element of each of
the lists .
in the messWin:
-- Welcome to Director --
dObj = new ( script "liststepperObj" )
a = [1,2,3,4,5,6]
b = [#a,#b,#c,#d,#e,#f,#g,#h]
c = ["red","blue","green"]
LoL = [a,b,c]
dObj.init(LoL)
put dObj.incrStep()
-- [2, #h, "blue"]
-- [1, #g, "red"]
-- [6, #f, "green"]
-- [5, #e, "blue"]
-- [4, #d, "red"]
-- [3, #c, "green"]
-- [2, #b, "blue"]
-- [1, #a, "red"]
-- parent script "listStepperObj
-- dp
property myLoL,myCounter
on new me
return me
end
on init me, dLoL
myLoL = dLoL
end
on incrStep
myCounter = myCounter + 1
dLresults = []
cnt = myLoL.count
repeat with i = 1 to cnt
dL = myLoL[i]
dC = dL.Count
dPos = myCounter mod dC
if dPos = 0 then dPos = dC
dLresults.append( dL[dPos] )
end repeat
return dLresults
end
-- End of script
|