Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

What and how to use "Action Clauses" in AppleScript?

ignoring application responses


-- insert actions here

end ignoring


with timeout of 180 seconds


-- insert actions here

end timeout


with transaction


-- insert actions here

end transaction

What and how to use the above?

Posted on May 29, 2015 11:52 PM

Reply
2 replies

May 30, 2015 1:05 AM in response to Nob-Nobita-Cube

These commands alter AppleScript's typical behavior.


In the first case, AppleScript normally executes commands serially - that is, it tells an application to do something, waits for that command to finish, then it executes the next statement.


With the 'ignoring application responses' command you basically tell AppleScript to issue the commands blindly, and not to wait for the result.

This can mean things happen quicker (because you're not waiting for each command to finish before moving on), but it also means you can't catch errors that happen in the script. Sometimes that's OK.


For with timeout..., AppleScript has a built-in timeout for commands (60 seconds, IIRC), after which it assumes that something went wrong and it cancels the script. If that timeout isn't long enough (e.g. you know your command may take several minutes, or hours, to execute) then you can wrap the commands in a 'with timeout' statement which tells AppleScript to wait longer (or shorter) before canceling a script.

Note this does not have any effect on the actual execution of the commands - they will still run as quickly as they can - it's only a matter of how long AS waits before giving up.


with transaction is a different beast. Some applications (but not many) support transactions, where you can wrap multiple commands into a single group such that they must all execute, or must not. This is most common in database-type applications where you need to lock a table to perform certain updates. Few applications have use for this, though.


More details on these (and other control statements) can be found at https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual/App leScriptLangGuide/reference/ASLR_control_statements.html

What and how to use "Action Clauses" in AppleScript?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.