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 write some text out to a file using AppleScript's write command (Scripting Addition).

Sample
var theText = "Some text";
var startupDiskName = MacOS.finder().desktop.startup_disk.name;
var outputFile = new MacOS.FileSpec(startupDiskName + ":Desktop Folder:test.html");

with (MacOS.appSelf()) {
    var fileRef = open_for_access(outputFile, true);

    try {
        write(theText, null, null, fileRef);
        close_access(fileRef);
    }
    catch (e) {
        close_access(fileRef);
        throw e;
    }
}

 

 

 

 

 

 

 

 

 

 


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