从单独的工作流更改工作流中的变量
Change the variable in a workflow from a separate workflow
我有两个工作流,我需要将一个工作流中生成的值传递给另一个工作流。
在我的第一个工作流程中,我有一个 AppleScript,其中 return 是我想放入第二个工作流程中的数字,我从第一个工作流程调用它,如下所示:
我的第二个工作流程(在 iStudiez 中创建 Class)有一个变量 'Class Number',当我使用 AppleScript 的 return 值从我的第一个工作流程调用它时,我想更改它如上图
由于您在 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
我有两个工作流,我需要将一个工作流中生成的值传递给另一个工作流。
在我的第一个工作流程中,我有一个 AppleScript,其中 return 是我想放入第二个工作流程中的数字,我从第一个工作流程调用它,如下所示:
我的第二个工作流程(在 iStudiez 中创建 Class)有一个变量 'Class Number',当我使用 AppleScript 的 return 值从我的第一个工作流程调用它时,我想更改它如上图
由于您在 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