1

是否可以在自动化工作流程中存储持久值(特别是对于服务流)?

似乎常规的自动机变量不是持久的;例如,尝试使用具有属性(通常持续存在)的 applescript 块实际上也不会在 Applescript 中持续存在该属性(在测试中有效,但是当您运行服务时,该值不会持续存在)。

有任何想法吗?

4

1 回答 1

4

您可以使用脚本对象将数据存储在不碍事的地方。

自动机

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
于 2012-11-11T05:22:44.900 回答