How to increase count on variable

Solution 1:

You are specifically setting myUpDownCnt as a local variable, value 0 at the beginning of each idle function entry.

Instead make it a a global, outside your function, so you only define it once.

global myUpDownCnt      -- declare myUpDownCnt
set myUpDownCnt to 0    -- initialize myUpDownCnt

on function ()
    set myUpDownCnt to (myUpDownCnt + 1)
end function