use (scripting additions)

By default, when one or more use statements are added to a script, support for scripting additions must be manually enabled by adding another use statement concerning scripting additions:

use scripting additions

NOTE: use scripting additions has no specifier data and no additional parameters.

Discussion

If a script has one or more use commands, scripting addition commands are handled differently in two ways.

First, scripting addition commands are not available by default. You must explicitly indicate when you wish to use scripting additions, either with a use or a using terms from command.

use scripting additions

display dialog "hello world"

using terms from scripting additions
display dialog "hello world"
end using terms from

scraddexample

 (⬆ see above left Error on compile, because the script contains a use statement for importing a script library, but no use statement for allowing scripting additions commands, such as display dialog.

 (⬆ see above right Script with use statement for importing script library, also includes use statement specifying the use of scripting additions.

Second, AppleScript may optimize scripting addition commands, sending them to the current application instead of the current target (it) when it does not change the meaning to do so.

For example, the scripting addition command: random number does not need to be sent to another application to work correctly, and will always be sent to the current application when imported in a use statement.

Without a use scripting additions command, AppleScript must use a less efficient dispatching scheme, so explicitly declaring them is recommended.

TOP | CONTINUE