//global variables definition [VarDef,gnumberOfLayers,0] [VarDef,gLayerPath(256),""] [VarDef,gScrollPos(256),0] [VarDef,gLayerState(256),0] [VarDef,tmpLyScrPos,0] //****routine to find the number of layers***************** [RoutineDef,GetLayers, [VarSet,gnumberOfLayers,0] [If,[IsEnabled,Tool:Layers:Layers Scrollbar], //store current scroll bar position [VarSet,tmpLyScrPos,[IGetSecondary,Tool:Layers:Layers Scrollbar]] //set scroll bar to a maximum to ensure it is at the top [ISet,Tool:Layers:Layers Scrollbar,0,256] [VarSet,gnumberOfLayers,[IGetSecondary,Tool:Layers:Layers Scrollbar]+1] , [If,[IsEnabled,"Tool:Layers:Layer Intensity"], [VarSet,gnumberOfLayers,1] ] ] ]//end routine [IButton,GetLayerStates,"Store states & paths of all layers", [RoutineCall,GetLayers] //get the active path position [Loop,gnumberOfLayers, [ISet, Tool:Layers:Layers ScrollBar, 0, [Val,n]] [VarSet,activePath,[StrMerge,"Tool:Layers:",[IGetTitle,"Tool:Layers:Layer Intensity"]]] [If,[IGetFlags,activePath]>=10, [VarSet,activeScrollPos,[Val,n]] [LoopExit] ] ,n] //select lowest layer [Loop,gnumberOfLayers, [If,[IsEnabled,"Tool:Layers:Select Down"], [IPress,"Tool:Layers:Select Down"] ] ] //position scroll bar so lowest layer at position '0' [ISet, Tool:Layers:Layers ScrollBar, 0,0] //get the layer states [Loop,gnumberOfLayers, [VarSet,gLayerPath(n),[StrMerge,"Tool:Layers:",[IGetTitle,"Tool:Layers:Layer Intensity"]]] [VarSet,gScrollPos(n),[IGetSecondary, Tool:Layers:Layers ScrollBar]] [VarSet,gLayerState(n),[IModGet,gLayerPath(n)]] [ISet, Tool:Layers:Layers ScrollBar, 0,[Val,n]] [If,[IsEnabled,"Tool:Layers:Select Up"], [IPress,"Tool:Layers:Select Up"] ] ,n] //reset to active layer [ISet,Tool:Layers:Layers ScrollBar,0,[Val,activeScrollPos]] [IPress,activePath] //reset scrollbar position [ISet,Tool:Layers:Layers ScrollBar,0,tmpLyScrPos] ] [IButton,"Select Third Layer","Select third layer from top", //no error checking! [VarSet,index,gnumberOfLayers-3]//adjust as our list starts at bottom [ISet,Tool:Layers:Layers ScrollBar,0,[Val,gScrollPos(index)]] [IPress,[Var,gLayerPath(index)]] ]