LNS Home
JavaScript OSA
JavaScript OSA Home
Download & Installation
QuickStart
Project Status
Documentation
 
Object Reference
 
Core
MacOS
MacOS.AEDesc
MacOS.AEApp
MacOS.AEClass
MacOS.AEColl
MacOS.FileSpec
MacOS.OSA
MacOS.MacOSError
Sending Raw AppleEvents
Responding to AppleEvents
AppleEvent to JavaScript Value Conversion
How-Tos
 
Open Handler
Folder Actions Handlers
Write Some Text
Calling JavaScript from REALbasic
Using JavaScript Libraries
FAQ
Mailing List
JavaScript Language Documentation & Links
Products
x Script Debugger 4.5
Site Contents
bullet Mark’s Blog
Product Registration
Bug Reporting
x Freeware
Contacting Us

AppleEvent to JavaScript Value Conversion

The MacOS.AEApp, MacOS.AEClass and MacOS.AEColl objects perform JavaScript to AppleEvent conversions when sending AppleEvents to another Macintosh Application. AppleEvent to JavaScript conversions are performed on the result of an AppleEvent.

JavaScript To AppleEvent Value Conversions

JavaScript Value AppleEvent Value
string string
integer long integer
float long float
boolean boolean
array list
object record
(see notes below)
MacOS.FileSpec file specification
MacOS.AEDesc the AEDesc value
undefined undefined
null missing value

AppleEvent To JavaScript Value Conversions

AppleEvents have a greater number of ways of expressing values than does JavaScript. Because of this, JavaScript OSA AppleEvent to JavaScript conversion process maps several AppleEvent data types onto a single JavaScript data type.

AppleEvent Value JavaScript Value
string
international string
styled string
unicode string
P-string
C-string
string
long integer
short integer
magnitude
integer
long float
short float
float
boolean
true
false
Boolean
file specification
alias
MacOS.FileSpec
list array
record object
(see notes below)
undefined undefined
missing value null
anything else MacOS.AEDesc

JavaScript Object/AppleEvent Record Conversions

An AppleEvent record is a collection of properties, much as a JavaScript Object is. The difference is that there may be two kinds of property in an AppleEvent record: keyed properties and user properties.

A keyed property is identified by a unique 4-character key that usually maps to a property definition in an application dictionary. If the AppleEvent/JavaScript conversion is performed by a method or property of the MacOS.AEApp, MacOS.AEClass or MacOS.AEColl objects, keyed properties in JavaScript may be referred to using the name defined for the key in the target application's dictionary. If the conversion is happening in any other context, the JavaScript name given to the property is "ae_xxxx" where xxxx is the property's four-character.

NOTE: if a property key contains characters that cannot appear in a JavaScript identifier, use JavaScript's array syntax to access the property (e.g.: aVar["ae_----"]).

A user property is a named property where the name is an arbitrary string of any length (there is a generally accepted 255 character limit). User properties map directly to properties of JavaScript objects.


Copyright © 1998-2009 Late Night Software Ltd. - All Rights Reserved.