en fr

Sysquake Pro – Table of Contents

Sysquake – Table of Contents

Sysquake for LaTeX – Table of Contents

Extension - Open Scripting Architecture

This section describes functions which support the Open Scripting Architecture of Mac OS, i.e. a system-level mechanism which supports different computer languages such as AppleScript.

Functions

doscript

Execution of a script by another Mac OS application.

Syntax

doscript(target, script)
reply = doscript(target, script)

Description

doscript(target,script) requests the application identified by the four-character signature in string target to execute the script in string script. If doscript has an output argument, a reply is returned in a string.

Data exchange involved by doscript is performed with AppleEvents, a process-to-process communication mechanism specific to Mac OS. Not all applications accept the doscript AppleEvent.

Example

Ask Matlab to perform a matrix inversion and inverse it back with LME. Note how the precision argument of the Matlab function num2str is used to retrieve all significant digits; in LME, dumpvar could be used instead.

reply = doscript('MATL','disp(num2str(inv([2,3;1,7]),16))')
  reply =
    0.6363636363636364  -0.2727272727272727
   -0.09090909090909091  0.1818181818181818
Mi = eval(['[', reply, ']'])
  Mi =
    0.6364    -0.2727
   -9.0909e-2  0.1818
norm(inv(Mi) - [2,3;1,7])
  ans =
    1.5249e-15

osascript

Execution of a script.

Syntax

osascript(script)
osascript(script, osaName)
reply = osascript(...)

Description

osascript(script) requests the default OSA scripting language (normally AppleScript) to execute script. A second input argument can be used to specify the name of the scripting language (such as 'AppleScript' or 'JavaScript', depending on which OSA component is installed on the computer; see osascriptlist). An output argument can be used to request a string reply.

Example

Display a dialog box and get the label of the button clicked by the user:

dlg = ['display dialog "Which color?" ',...
       'buttons {"Blue", "Red"} ',...
       'default button "Blue"'];
s = osascript(['the button returned of (', dlg, ')'])
  s =
    Red

See also

osascriptlist

osascriptlist

List of available OSA scripting languages.

Syntax

list = osascriptlist

Description

osascriptlist gives the list of scripting languages which are installed and can be used with osascript.

See also

osascript