Reputation: 41
I have a problem with variables not working outside an idle. What should I do to make it work? My code looks like this:
set currentdate to current date
set currentminute to currentdate's minutes
on idle
display dialog currentminute
if idle_time < 0 then set idle_time to days - (time of (current date))
return idle_time
end idle
Upvotes: 0
Views: 121
Reputation: 285260
on idle
is not a loop, it's a handler having its own scope.
Mark currentminute
as global
or declare it as property
for example. Both ways makes the variable available in handlers on lower levels.
property currentminute : 0
set currentdate to current date
set currentminute to currentdate's minutes
on idle
display dialog currentminute
if idle_time < 0 then set idle_time to days - (time of (current date))
return idle_time
end idle
Upvotes: 1