Cancel
Showing results for 
Search instead for 
Did you mean: 

Max value of a buffer

Experimenter
Experimenter

How can I get the MU with the highest time value attached to it, to get out of the buffer first?

 

 

I need a script that can be put into a method, so no sorter can be used.

1 REPLY

Re: Max value of a buffer

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

you can use the method maxAttr of the contents list of the buffer e.g. (not tested!!)

var t:table
t.create
--read content of the buffer
buffer.contentsList(t)

if t.yDim=0 then
  debug --buffer is empty
else
  --search the highest value 
  t.setCursor(1,1)
  t.maxAttr([1,1}..{1,*},"YourAttribute")
  --move the MU from the selected row
  t[1,t.cursorY].move(yourDestination)
end
Steffen Bangsow
freelance simulation specialist  
web: www.bangsow.eu
mail: steffen@bangsow.net