J'essaie de mettre à jour un compteur mais il est remis à zéro à chaque fois que la boucle de répétition démarre. La variable en question est myUpDownCnt.
on roundThis(n, numDecimals)
set x to 10 ^ numDecimals
(((n * x) + 0.5) div 1) / x
end roundThis
on idle
set myTime to time of (current date) as string
set myAvg to 1.08
set myUpDownCnt to 0
repeat until myTime = true
set myTimeB to (round ((time of date ((current date) as string)) / 60) rounding down) mod 5 = 0 --every 5 minutes
if myTimeB then
quit application "Numbers"
tell application "Numbers" to open POSIX file "/Users/steve 1/Documents/Document.numbers"
tell application "Numbers"
tell the table 1 of sheet 1 of document "Document"
set myAvg to the value of cell "C57"
set myAvgPrior to the value of cell "E57"
end tell
end tell
set myAvgDiff to myAvg - myAvgPrior
set myDiffPercent to myAvg / myAvgPrior - 1
if myAvgDiff > 0 then
if myUpDownCnt < 0 then
set myUpDownCnt to 1
else
set myUpDownCnt to myUpDownCnt + 1
end if
say "Increasing " & myUpDownCnt & " times in a row"
else
if myAvgDiff = 0 then
say "No change."
else
if myUpDownCnt > 0 then
set myUpDownCnt to -1
else
set myUpDownCnt to myUpDownCnt - 1
end if
say "Decreasing " & -myUpDownCnt & " times in a row"
end if
end if
end if
return 60 --less than 60 may cause it to get double triggered.
end repeat
end idle
on quit {}
display dialog "Are you sure you want to quit?"
continue quit -- quits the applet
end quit