Code: Select all
<Globals>(block nil
(setq loopCrement (lambda (current start stop increment) (block (new)
(setq new (add current increment))
(switch
(and (gr increment 0) (gr new stop))
(setq new (add start (subtract new stop) -1 ))
(and (ls increment 0) (ls new start))
(setq new (add 1 (subtract stop (subtract start new))))
)
new
)))
(setq lctest (lambda () (block nil
(setq x 5)
(for i 1 10 (dbgOutput (setq x (loopCrement x 5 12 1))))
(dbgOutput "-----------")
(for i 1 10 (dbgOutput (setq x (loopCrement x 5 12 -1))))
)))
(setq lctest2 (lambda () (block nil
(setq x 5)
(for i 1 10 (dbgOutput (setq x (loopCrement x 5 12 3))))
(dbgOutput "-----------")
(for i 1 10 (dbgOutput (setq x (loopCrement x 5 12 -3))))
)))
)</Globals>
Code: Select all
<init screen>
(setq pages (list 'page1 'page2 'page3 'page4 'page5))
(setq curpage 0)
</init screen>
<init pane>
(setPaneDesc gScreen (cat "Currently viewing " (item pages curpage) "."))
</init pane>
<action next>
(setq curpage (loopCrement curpage 0 (count pages) 1)
</action next>
<action previous>
(setq curpage (loopCrement curpage 0 (count pages) -1)
</action previous>
<action pagedown>
(setq curpage (loopCrement curpage 0 (count pages) 5)
</action pagedown>
<action pageup>
(setq curpage (loopCrement curpage 0 (count pages) -5)
</action pageup>
I got the idea to reimplement this function when I saw TransGeek doing something like this with his inventory categories mod, and doing some clunky loop-end checkings in the up/down actions for it.