Applescript 从单独的工作流更改工作流中的变量

Applescript 从单独的工作流更改工作流中的变量,applescript,automator,Applescript,Automator,我有两个工作流,我需要将一个工作流中生成的值传递给另一个工作流 在我的第一个工作流中,我有一个AppleScript,它返回一个我想输入到第二个工作流中的数字,我从第一个工作流调用该数字,如下所示: 我的第二个工作流(在iStudiez中创建类)有一个变量“类编号”,当我从第一个工作流调用它时,我想更改它,返回值为上图中的AppleScript。因为您在Automator中使用Automator和AppleScript,并且您没有发布任何实际代码,很难给你一个确切的答案,你在寻找什么 可能有一个

我有两个工作流,我需要将一个工作流中生成的值传递给另一个工作流

在我的第一个工作流中,我有一个AppleScript,它返回一个我想输入到第二个工作流中的数字,我从第一个工作流调用该数字,如下所示:


我的第二个工作流(在iStudiez中创建类)有一个变量“类编号”,当我从第一个工作流调用它时,我想更改它,返回值为上图中的AppleScript。

因为您在Automator中使用Automator和AppleScript,并且您没有发布任何实际代码,很难给你一个确切的答案,你在寻找什么

可能有一个更简单的解决方案,但我提出的解决方案是创建一个脚本,将变量保存到一个新的脚本文件中(该文件将在桌面上以“Stored_variable.scpt”的名称自动创建)。第二个脚本加载存储在“Stored_variable.scpt”文件中的变量值

只需将第一个脚本中的代码直接粘贴到包含要复制的变量的代码中。请确保将代码粘贴到设置要复制的变量值的代码之后

--  Comment Out This Next Line Before
--    Placing This Code Into Your Script
--    Which Contains The Variable You Want Copied

set originalVariable to (path to desktop) -- Testing Purposes Only

-- Replace "originalVariable" with the
--   Name Of Your Actual Variable You Want To Pass
--   To The Next Script

set saveThisVariable to originalVariable
storeTheVariable()

-- The Following Code Belongs At The Very Bottom Of Your Script
on storeTheVariable()
    set storedVariabeFileLocation to (path to desktop as text) & "Stored_Variable.scpt"
    ----------------------
    script theVariable
        set saveThisVariable to saveThisVariable
    end script
    ----------------------
    store script theVariable in ¬
        file storedVariabeFileLocation with replacing
end storeTheVariable

将这是第二个代码放在AppleScript的代码中,您试图在其中检索从第一个AppleScript代码存储的变量

-- Gets The Variable Which Was Previously Stored
--   From The Other Applescript And Stores It In A
--   New Variable... getVariableNow

set getVariableNow to run loadTheVariable

-- -----------------------------------

-- Place Whatever Commands Here, That You Will Be Using
--   The New Variable... getVariableNow with

-- -----------------------------------

-- The Following Code Belongs At The Very Bottom Of Your Script
script loadTheVariable
    property storedVariabeFileLocation : (path to desktop as text) & "Stored_Variable.scpt"
    property theRetrievedVariable : missing value
    on getStoredVariable()
        set theScript to load script file storedVariabeFileLocation
        set theRetrievedVariable to saveThisVariable of (theVariable of theScript)
    end getStoredVariable
    set theRetrievedVariable to loadTheVariable's getStoredVariable()
end script

Automator并没有阻止我使用带有空格的变量。我是新手,我知道它的编程很糟糕,但它可以工作。至于你的第二点,我想问的是,是否有人知道如何在定义的工作流之外更改变量。我不需要指定在第二个工作流中会发生什么。这与此无关。