Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

macstatic

macrumors 68020
Original poster
Oct 21, 2005
2,029
168
Norway
What's wrong with the following Applescript (it works fine in the Applescript editor) when I use it with Automator?:
Code:
display alert "Bold title here" as warning message "More text here" buttons {"OK"} default button "OK"

It looks like this in the "Run Applescript" Automator action -I've just pasted the Applescript into where it says (* Your script goes here *):
Code:
on run {input, parameters}
 
    (display alert "Bold title here" as warning message "More text here" buttons {"OK"} default button "OK")
 
    return input
end run

The error message I get is:

Syntax error
Expected “,” but found “"”.
 
I think a more interesting question is why it works outside Automator. In short, the syntax of the display alert command is wrong. It should be something like:

Code:
on run {input, parameters}

   display alert "Bold title here" message "More text here" as warning buttons {"OK"} default button "OK"
   return input

end run

...note the position of the "as warning". If in doubt, always take a peek in the scripting dictionary:


display alert
display alert (verb)Display an alert (from the User Interaction suite, defined in StandardAdditions.osax)

function syntax
set theResult to display alert text ¬
message text ¬
as as ¬
buttons list of text ¬
default button text or integer ¬
cancel button text or integer ¬
giving up after integer
message text ¬
as as ¬
buttons list of text ¬
default button text or integer ¬
cancel button text or integer ¬
giving up after integer
message text ¬
as as ¬
buttons list of text ¬
default button text or integer ¬​
cancel button text or integer ¬
giving up after integer
result
alert replya record containing the button clicked​
 
Thanks! That worked fine (in both AppleScript editor and Automator) but I'm unable to find the scripting dictionary you're referring to and none of the links above work.
I was hoping to further figure out how to use custom app icons as I've successfully done that in Applescript in combination with the two dialog lines (the first one being bold) as in my above script:

Code:
display dialog "Backup done!" with icon file "Applications:Utilities:Terminal.app:Contents:Resources:Terminal.icns" buttons "OK" default button "OK"

Apparently it's not a simple matter of inserting "with icon file....." after the text and removing "as warning"
 
Thanks! That worked fine (in both AppleScript editor and Automator) but I'm unable to find the scripting dictionary you're referring to and none of the links above work.

Sorry. I probably confused the issue by copying and pasting out of Script Debugger.

If you're in Script Editor then go to File>Open Dictionary and look for "Standard Additions". The documentation for the display alert command is in there.

I don't think display alert lets you supply an icon file, but display dialog does.
 
OK, I found the dictionary in the Applescript editor where I opened "Standard additions" -it seems you're right: there isn't an option for adding custom icons to display alert though with display dialog it's possible.
Hmmmm..... I'm a little confused myself.. I can't seem to find any of my Applescript files containing both a bold title with a normal 2nd line of text (display alert) along with a custom icon (display dialog), so perhaps it's not even possible in Applescript either.

I came across some interesting reading in this posting where the answer seems to indicate that the code
using terms from application "Finder" can be used to make Automator accept standard Applescript code. If my understanding is correct, this could possibly be used for any Applescript code which otherwise wouldn't work in Automator, but if the code won't work in Applescript itself to begin with that won't be of any use :confused:

Maybe I should just settle for the easier to read message (bold title, normal 2nd line of text) with a standard icon :)
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.