What I would like to do is make a workflow that prompts the user for 3 variables when it first starts running, and save them as var1, var2, and var3.
I can do this without a problem. But what I want to do, is later in the workflow, access these variables inside an applescript. I don’t know how to do this because only one variable gets passed to the applescript in automator, which is the “input”. How can I access these other variables and use them in the applescript?
I have a potential solution but I’m not sure how to fully use it yet.
Using this:
on run {message, parameters}
display dialog "Enter Message 1" default answer "one"
set message1 to text returned of result
display dialog "Enter message 2" default answer "two"
set message2 to text returned of result
set message to {message1, message2}
return message
end run
I can save {“one”,“two”} to an automator variable, and then recall it later in applescript. The only thing I can’t do now, is how do I separate those back out in Applescript to set them each as different things?
EDIT: Ah, to seperate them, you just do
set myVar to (item 1 of input)
etc
so I’ve got some code that grabs a URL from safari, breaks it into parts, and then I need to ftp upload the parts based on the folPath and filename; How do I break them apart and access each one in automator?
Here’s my code; how do I access both folpath and filename inside of automator?
on run {input, parameters}
global theURL
global filename
global folPath
tell application "Safari"
set theURL to URL of document 1
end tell
if theURL begins with "http://" then set theURL to text 8 thru -1 of theURL
set {tid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, "/"}
set vars to text items of theURL
set {domain, filename} to {item 1, item -1} of vars
if (count vars) ≥ 3 then
set folPath to items 2 thru -2 of vars as string
else
set folPath to null
end if
set AppleScript's text item delimiters to tid
return {filename, folPath}
end run
I’m not sure if this will be of any help, but it might. I was looking in to using variables within automator a while back and stumbled on this article.