Kev*_*vin 1 applescript increment count counting
我有一个 AppleScript 保存为应用程序,我每天运行它几次,并且我想添加一个计数器。
property currentCount : 0
increment()
on increment()
set currentCount to currentCount + 1
display dialog "Count is now " & currentCount & "."
end increment
Run Code Online (Sandbox Code Playgroud)
即使我关闭并再次打开它,每次脚本运行时都会添加 1,但如何重置它?
我的意思是,目标是每天计算“病例”的数量,然后在第二天重新开始。
怎样才能第二天自动重置?
干杯
试试这个,它使用当前日期的附加属性。
property today : missing value
property currentCount : 0
increment()
on increment()
set currentDate to short date string of (current date)
if currentDate is not today then
set today to currentDate
set currentCount to 0
end if
set currentCount to currentCount + 1
display dialog "Count is now " & currentCount & "."
end increment
Run Code Online (Sandbox Code Playgroud)