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
Affrus 1.0
x FaceSpan 4.3
Script Debugger 4.0
Site Contents
Home Page
bullet Mark’s Blog
Product Registration
Bug Reporting
x Freeware
Contacting Us

How-To Write an Open Handler

Here's a sample showing how to declare a handler that responds to the Open Document AppleEvent (the one generated when you drop files onto a script using the Finder). This sample also shows how to ask the Finder for information about a file.

Sample
function open(AE_params) {
    var theFiles = AE_params.of;
    var theNames = "";

    for (var i = 0; i < theFiles.length; ++i) {
        with (MacOS.finder()) {
            if (theNames != "")
                theNames += ", ";

            // ask the Finder for the name of the file
            theNames += newReference(_types.item, theFiles[i]).name;
        }
    }

    MacOS.message("open: " + theNames);
}

 

 

 

 

 

 

 


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