是否可以在自动机工作流程中存储持久值(特别是服务流程)?似乎常规自动机变量are not persistant并尝试使用applescript chunk which has a property(通常是持久的)并不会实际上在Applescript中保留该属性(在测试中有效,但是当您运行服务时价值不会持续)。有什么想法吗?
答案 0 :(得分:2)
您可以使用脚本对象将数据存储在不受影响的地方。
on run
-- Path of script which holds data
set thePath to (path to desktop as text) & "myData.scpt"
--set thePath to (path to preferences as text) & "myData.scpt" -- better
script theData
property xxx : missing value
end script
try
set theData to load script file thePath
on error
-- On first run, set the initial value of the variable
set theData's xxx to 5
end try
-- change the value of the variable
set theData's xxx to (theData's xxx) + 1
-- save your changes
store script theData in file thePath replacing yes
return theData's xxx
end run