TOP | UP: Reference |
This chapter provides reference information for the verbs described under "Apple Event Suites" in Chapter 32, Driving Other Applications.
core.close (appID, whatObject, [saving?, savingIn])
Closes whatObject. The values for saving? are yes, no, and ask; the default is no.
theApp = "Scriptable Text Editor"
with objectModel
core.close(theApp, window[1])
core.count (appID, container, whatToCount)
Returns the number of whatToCounts (some type of element) in container. If there is no container, pass null.
theApp = "Finder"
with objectModel, finder
msg(core.count(theApp, null, disk))
core.create (appID, whatClass, [data, propertyList, where])
Makes a new whatClass (some type of element). This concept is sometimes called "make" in other literature.
core.dataSize (appID, whatObject, [whatType])
Returns the size of the data of whatObject; whatType says what type of object whatObject should be considered as, because this can make a difference to the size of its data.
theApp = "Scriptable Text Editor"
with objectModel, window[1]
msg(core.dataSize(theApp, word[4], text))
« 4, because that's how many letters it has
msg(core.dataSize(theApp, word[4]))
« 58, because it includes style information
core.duplicate (appID, whatObject, toWhere)
Makes a copy of the element whatObject at toWhere. This concept is sometimes called "clone" in other literature.
theApp = "Scriptable Text Editor"
with objectModel, document[1]
core.duplicate(theApp, word[2], after(word[3]))
core.get (appID, whatObject, [whatType])
Returns the data of whatObject; whatType says what type of object whatObject should be considered as.
theApp = "Scriptable Text Editor"
with objectModel, window[1]
msg(core.get(theApp, word[4], text))
« "time"
« if we omit the third parameter, we get a mess...
« because of the style information
core.getAs (appID, whatObject, whatType)
Identical to core.get() except that whatType isn't optional.
core.quit (appID, [saving?])
Quits the application; possible values for saving? are yes, no, and ask, and the default is ask.
core.save (appID, whatObject, [filePathname, fileType])
Saves to disk. fileType is a string4 type code. There is a bug in the glue; the filePathname is coerced to an alias, when it should be coerced to a fileSpec. This is true for the save() and saveAs() of just about all application glue as well.
core.saveAs (appID, whatObject, filePathname, [fileType])
Identical to core.save() except that filePathname isn't optional.
core.set (appID, whatObject, toWhat)
Sets the value of whatObject to toWhat. A powerful command, the commonest way of getting real work done. This example boldifies the selected stretch of text.
local (theApp = "Scriptable Text Editor")
with objectModel, STE « Scriptable Text Editor glue
stylRec = {onStyles:{bold}, offStyles:{}}
core.set(theApp, selection.style, stylRec)
misc.beginTransaction (appID)
Asks the application to start a transaction and to return a transactionID.
misc.copy (appID)
Like choosing Copy from the application's Edit menu. Most applications must be frontmost for this command to work.
misc.createPublisher (appID, whatObject, whatFile)
Causes the application to make a publish-and-subscribe publisher of whatObject in the edition file whatFile.
misc.cut (appID)
Like choosing Cut from the application's Edit menu. Most applications must be frontmost for this command to work.
misc.doMenu (appID, whatMenuItem)
Like choosing whatMenuItem. In this example, we ask FileMaker Pro to boldify the currently selected text.
theApp = "FileMaker Pro"
with objectModel
misc.doMenu(theApp, menu["Style"].menuitem["Bold"])
misc.doScript (appID, string)
Causes the application to execute a script in its internal scripting language.
misc.editGraphic (appID, graphicArea)
Tells the application to open graphicArea for editing, so that the user can edit it; when the user has finished the editing session, returns the edited graphic.
misc.endTransaction (appID, transactionID)
Asks the application to end a transaction. This is the only verb in the database that calls transactionEvent().
misc.imageGraphic (appID, graphic, format, antialiasing?,
dithering?, rotationRec, scale,
translationPoint, flipHorizontal?,
flipVertical?, quality,
structuredGraphic?)
Performs a graphic image conversion. All but the first three parameters are optional. The format is a string4 type code such as 'EPS ', 'PICT', or 'TIFF'. The quality can be draft, high, or regular. To avoid passing large amounts of data, both the graphic and the result can be an alias to a file.
misc.isUniform (appID, whatObject, whatProperty)
Returns a boolean telling whether the object(s) whatObject all have the same value for the property whatProperty.
misc.paste (appID)
Like choosing Paste from the application's Edit menu. Most applications must be frontmost for this command to work.
misc.revert (appID, whatObject)
Reverts the object whatObject to its most recently saved state.
misc.select (appID, whatObject)
Causes whatObject to become the current selection. A shorthand for using core.set() with direct object selection.
theApp = "Scriptable Text Editor"
with objectModel
misc.select(theApp, window[1].word[2])
« same as saying:
« core.set(theApp, selection, window[1].word[2])
required.openApplication (appID)
Sent to an application immediately after it is started up. Tells the application to perform its initialization tasks, such as opening an empty document. Apple Computer says that you should never call this verb (only the Finder may do so).
required.openDocument (appID, documentPathname)
Sent to an application when the user opens one of its documents in the Finder; if the application wasn't running, sent instead of required.openApplication(). Tells the application to open the document.
TOP | UP: Reference |