AppleScript Studio AppleScript AppleScript Stduio Objective-C Cocoa Cocoa Objective-C Java AppleScript AppleScript Studio Application Suite call method call method [of class ] [of object ] [with parameter ] [with parameters ] call method Objective-C More on AppleScript Studio http://developer.apple.com/techpubs/macosx/coretechnologies/applescriptstudio/applescripts tudio/chapter3/more_on_app_ript_studio.html Objective-C MDOnline 2002 2 7 1
Objective-C Objective-C C Toolbox API Cocoa Objective-C Java Carbon API C API Objective-C Java Pure Java Java AppleScript Java Objective-C Project Builder AppleScript Application Objective-C Command+N Cocoa Objective-C MDOnline 2002 2 7 2
SoundPlay.m SoundPlay.m SoundPlay.h 2 /System/Library/Sounds ~/Library/Sounds AIFF.aiff NSSound MDOnline 2002 2 7 3
// SoundPlay.h #import <Cocoa/Cocoa.h> @interface SoundPlay : NSObject { + (void)playsound; + (void)playsound:(nsstring *)soundname; + (void)playsound:(nsstring *)soundname async:(bool)isasync; @end 3 playsound Foundation.h Cocoa.h playsound Temple 2 1 3 2 2 true 2 SoundPlay.h // SoundPlay.m #import "SoundPlay.h" @implementation SoundPlay MDOnline 2002 2 7 4
+ (void)playsound; { NSSound * thesound = [NSSound soundnamed:@"temple"]; [thesound play]; + (void)playsound:(nsstring *)soundname; { NSSound * thesound = [NSSound soundnamed:soundname]; [thesound play]; + (void)playsound:(nsstring *)soundname async:(bool)isasync; { NSSound * thesound; thesound = [NSSound soundnamed:soundname]; [thesound play]; if(isasync) while([thesound isplaying]) sleep(1); @end NSSound soundnamed play isplaying sleep 1 AppleScript call method "playsound" of class "SoundPlay" call method "playsound:" of class "SoundPlay" with parameter "Frog" call method "playsound:async:" of class "SoundPlay" with parameters {"Temple", true MDOnline 2002 2 7 5
of class "SoundPlay" 1 playsound 2 1 playsound 1 3 2 playsound playsound:async: AppleScript with parameter(s) Objective-C NSString * BOOL int with parameter {"Temple", true s 1 1 1 NSArray * 2 Cocoa NSNumber Java AppleScript Application Command+N Java class JavaObj.java MDOnline 2002 2 7 6
// JavaObj.java import com.apple.cocoa.foundation.*; import com.apple.cocoa.application.*; public class JavaObj { static public int actiona() { return 99; static public int actionb(int a) { return a*99; static public int actionc(int a, int b) { return (a+b)*99; static public NSArray actiond() { Object obj[] = {new Integer(19), "Sender OK", new Float(0.876); return new NSArray(obj); static public NSDictionary actione() { Object obj[] = {new Integer(19), "Sender OK", new Float(0.876); Object key[] = {"Age", "Message", "The Number"; return new NSDictionary(obj, key); static int stock = 0; static public void setstock(int n) { stock = n; static public int getstock() { return stock; AppleScript MDOnline 2002 2 7 7
actiona ActionC display dialog set x to call method "actiona" of class "JavaObj" display dialog x as string set x to call method "actionb:" of class "JavaObj" with parameter 10 display dialog x as string set x to call method "actionc::" of class "JavaObj" with parameters {10, 4 display dialog x as string actiona Java Objective-C Objective-C Java Java Objective-C actiond NSArray actione NSDictionary set x to call method "actiond" of class "JavaObj" display dialog (item 2 of x) as string set x to call method "actione" of class "JavaObj" display dialog (item 2 of x) as string display dialog (Age of x) as string actiond AppleScript actione NSDictionary AppleScript JavaObj static MDOnline 2002 2 7 8
setstock getstock static stock setstock getstock call method "setstock" of class "JavaObj" with property 123 set x to call method "getstock" of class "JavaObj" display dialog x as string static call method Java Math max 2 max:: set x to call method "max::" of class "java.lang.math" with parameters {3, 4 Objective-C API Java Java JDBC Java JDBC Java DataBase Connection SQL Java JDBC Microsoft SQL Server JBDC JDBC SQL SQL JDBC MDOnline 2002 2 7 9
OpenBase SQL OpenBase SQL WebObjects WebObjects OpenBase Mac OS X GUI OpenBase OpenBase WOMovies OpenBase International http://www.openbase.com/ WOMovies MOVIE OpenBase Manager NSTableView Interface Builder AppleScript MDOnline 2002 2 7 10
MainMenu.nib nib 1 Info clicked Application.applescript AppleScript Name AppleScript ASKDataSource NSTextView DataSource NSTableView 3 MDOnline 2002 2 7 11
Java Command+N Java class DBAccess // DBAccess.java import java.sql.*; import java.util.*; import com.apple.cocoa.foundation.*; import com.apple.cocoa.application.*; public class DBAccess { static public NSArray getdata(string criteria) { try { MDOnline 2002 2 7 12
Class.forName("com.openbase.jdbc.ObDriver"); Connection con = DriverManager.getConnection( "jdbc:openbase://localhost/womovies","",""); Statement st = con.createstatement(); ResultSet rs = st.executequery( "SELECT * FROM MOVIE WHERE TITLE LIKE '%" + criteria + "%'"); List tablecontents = new ArrayList(); while(rs.next()) { Object obj[] = {rs.getstring(1), rs.getstring("title"), rs.getstring("category"); tablecontents.add(new NSArray(obj)); rs.close(); con.close(); return new NSArray(tableContents.toArray()); catch(exception e) { System.out.println(e.getMessage()); return null; JDBC getdata 1 MOVIE SELECT LIKE SQL TITLE SELECT JDBC OpenBase localhost MDOnline 2002 2 7 13
OpenBase JDBC 2 NSArray NSArray 2 AppleScript 1 NSArray ArrayList toarray NSArray AppleScript on clicked theobject set crit to text field 1 of window of theobject set dbdata to call method "getdata:" of class "DBAccess" with parameter string value of crit set thetable to table view 1 of scroll view 1 of window of theobject set ds to data source 1 of thetable if (count data columns of ds) is 0 then make new data column at the end of data columns of ds make new data column at the end of data columns of ds make new data column at the end of data columns of ds end if delete data rows of ds repeat with arow in dbdata set newrow to make new data row at the end of data rows of ds set contents of data cell 1 of newrow to item 1 of arow set contents of data cell 2 of newrow to item 2 of arow set contents of data cell 3 of newrow to item 3 of arow end repeat end clicked Java DBAccess getdata call method MDOnline 2002 2 7 14
2 Hoo MDOnline 2002 2 7 15
100 Java Java 3 AppleScript Java call method AppleScript AppleScript AppleScript AppleScript Objective-C Java call method Mac OS X OSAX MDOnline 2002 2 7 16