In the Run Applescript Actions.
You output using the return someVar.
....
return text_returned
end run
And input to the Action is in the first argument normally name input
on run {input, parameters}
...
on run {input, parameters}
display dialog "test" default answer "" buttons {"Cancel", "OK"} default button 1
copy the result as list to {button_pressed, text_returned}
return text_returned
end run
on run {input, parameters}
set theQuery to input
end run
You would only need the set variable in this case if you wanted to reuse it.
In this example you could remove it and still get the same result.
If the argument is a list then you will need to use for example:
on run {input, parameters}
set theQuery to item 1 of input
end run
Also note that if you get your display dialog code from the applescript contextual/menus scripts it will give you the line : copy the result as list to {button_pressed, text_returned}
To use it in Automator you need to swap around the :{button_pressed, text_returned}
to {text_returned, button_pressed}
( Go figure..!)
set {button_pressed, text_returned} to {button returned, text returned} of result
orcopy {button returned, text returned} of result to {button_pressed, text_returned}
is much better, because then you don't really have to rely on the order of the properties, which are really specified to be unordered. So,approach shown works everywhere. – Iceland