wrapped page transversal [solved]

suppose I have a desktop with mxn pages, i am trying to write a function (mostly for exercise) that goes through each row then wrap around to the next:

[code]# go to next page in the order of row/col
DestroyFunc NextPage
AddToFunc NextPage

  • I PipeRead “if [ $[page.nx] == $$(($[desk.pagesx]-1)) ]; then
    echo “GotoPage wrapy 0 +1p”; else
    echo “GotoPage +1p +0p”; fi”

go to previous page in the order of row/col

DestroyFunc PrevPage
AddToFunc PrevPage

  • I PipeRead “if [ $[page.nx] == 0]; then
    echo “GotoPage wrapy $$(($[desk.pagesx]-1)) -1p”; else
    echo “GotoPage -1p -0p”; fi”[/code]

It doesn’t work: pages are only transversed horizontally, not wrapped. Seems that the if condition is never satisfied. Anyone?

–MZ

EDIT: Thanks to Thomas, solved. Working code below:

[code]DestroyFunc GoThruPages$
AddToFunc GoThruPages$

  • I PipeRead ‘case $0 in $
    next) test $[page.nx] -eq $$(($[desk.pagesx]-1)) $
    && echo GotoPage wrapy 0 +1p $
    || echo GotoPage wrapx +1p 0p;; $
    prev) test $[page.nx] -eq 0 $
    && echo GotoPage wrapy $$(($[desk.pagesx]-1)) -1p $
    || echo GotoPage wrapx -1p 0p;; $
    esac’$
    [/code]