Imported from the Apple Support Forums via the Wayback Machine 🔗
I simply want to set a variable in an AppleScript that's part of an Action, and be able to read it in other parts of the Action. You know:
set myVar to 50
Then use myVar in a second AppleScript later in the action.
Automator's "help" information for AppleScript variables is completely useless. Information about other kinds of variables doesn't apply ("Drag the variable into an editable field"???)
Imported from the Apple Support Forums via the Wayback Machine 🔗
Sorry, wrong terminology. The AppleScripts are parts of a Workflow, not an Action.
0
V.K.·
Imported from the Apple Support Forums via the Wayback Machine 🔗
this is not possible AFAIK. you need to output myVar from the first apple script and assign an automator variable to the result. you can access this variable later in the flow and pass it to the next apple script.
0
Barney-15E·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Use the Set Value of Variable and Get Value of Variable.
Have you Applescript return your variable value to a Set Value action; Retrieve the value by using a Get Value function which will be the input for your next applescript.
I don't know how you would pass out a variable and then continue working within the applescript.
0
red_menace·
Imported from the Apple Support Forums via the Wayback Machine 🔗
In addition to the Get/Set Value of Variable actions, you can use Automator's scripting terms to access it's workflow variables, for example:
title="this text can be pasted into an Automator 'Run AppleScript' action">
on run {input, parameters}
set output to {}
get the name of variables of front workflow
if the result is not {} then
set TheVariables to choose from list result with multiple selections allowed and empty selection allowed
if the result is false then error -128
repeat with SomeVariable in TheVariables
set the end of the output to (get value of variable SomeVariable of front workflow)
end repeat
end if
return output -- & input -- if desired
end run</pre>
0
G Robert Lewis·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Wow, awesome, thanks! How much MORE awesome it would be if this were actually documented somewhere! I Googled my fingertips off looking for something like this, and searched the Apple support site too. Nada. Zip.
I also discovered through trial and error that the "Script" window for the AppleScript variable can apparently contain code. For example, I made an AppleScript in the workflow that just said:
return "return "foo""
The next step was to set the variable myVar to the value emitted by this script.
The next step was to get the value of myVar. The Results pane had 2 lines:
return "foo" (presumably the actual script code in the variable)
foo (the result of evaluating the code)
And finally, the variable list showed that variable myVar had the value foo
This is kind of cool. But would it have killed them to document it?????