advertisement

Article:
  Controlling Your Mac with AppleScript and Java
Subject:   String resultString = results.stringValue(); Error CodeString resultString = results.stringValue();
Date:   2003-02-27 18:18:02
From:   thumbsup
Response to: String resultString = results.stringValue(); Error CodeString resultString = results.stringValue();

Scott,


I am including the entire .java file that is causing an error. Thanks for your help.


import com.apple.cocoa.foundation.*;


public class AppleScriptTest
{


public static void main(String[] args)
{
String script = "tell application \"Finder\" \n"
+ " get the name of the every item \n"
+ " in the desktop \n" + "end tell";
//This creates a new NSAppleScript
//object to execute the script
NSAppleScript myScript =
new NSAppleScript (script);
//This dictionary holds any errors that are
//encountered during script execution
NSMutableDictionary errors= new NSMutableDictionary();


//Execute the script!
NSAppleEventDescriptor results =
myScript.execute (errors);
//Print out everything on your desktop


System.out.println("Starting list of items "
+ "on the desktop: ");
int numberOfDesktopItems = results.numberOfItems ();
for (int i = 1; i <= numberOfDesktopItems; i++)
{
NSAppleEventDescriptor subDescriptor = results.descriptorAtIndex (i);
System.out.println (" " +
subDescriptor.stringValue() );

}
System.out.println("Yay AppleScript!");
}
}


1 to 1 of 1
  1. String resultString = results.stringValue(); Error CodeString resultString = results.stringValue();
    2003-02-27 20:50:42  sdwr98 [View]

    • String resultString = results.stringValue(); Error CodeString resultString = results.stringValue();
      2003-03-01 00:12:32  thumbsup [View]

1 to 1 of 1