Women in Technology

Hear us Roar



Article:
  Controlling Your Mac with AppleScript and Java
Subject:   Panther problems
Date:   2003-12-17 13:22:04
From:   sdwr98
Response to: Panther problems

I'm not seeing this problem... I did an Archive and Install of Panther, then got all the latest software updates.


Which example are you trying to run?

Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • Panther problems
    2004-01-18 18:11:53  coderanger [View]

    I am seeing the same thing. I even modified your code to compile a text script and execute it. A simple finder directory item list takes over 2 minutes real time when I execute using "time" to measure it. I an runnign on a pristin 12" powebook that same with Panther installed. I am going to try doing and exec of 'osascript' to see if that is better.

    Here is my code (modified from yours). It takes one command-line arg--a text fiel that is an Applescript.

    public class RunScript
    {
    public static void main(String[] args)
    {
    // shared NSApplication
    NSApplication.sharedApplication();

    // read in script file
    String scriptText = "";
    try {
    BufferedReader inStream = new BufferedReader(new FileReader(args[0]));
    String inputLine;

    while ((inputLine = inStream.readLine()) != null) {
    scriptText += inputLine + "\n";
    }
    } catch (IOException e) {
    System.out.println("IOException: " + e );
    System.exit(1);
    }


    // Script Object creation and execution
    NSAppleScript scriptObj = new NSAppleScript(scriptText);
    // dict for script exec errors
    NSMutableDictionary errorInfo = new NSMutableDictionary();
    // compile
    boolean compileResult = scriptObj.compile(errorInfo);
    System.out.println("Compile status:" + compileResult);
    // execute
    System.out.println("Running script...");
    NSAppleEventDescriptor aeResult = scriptObj.execute(errorInfo);

    // status report
    System.out.println("Script results complete..");

    if (aeResult != null ) {
    int itemCount = aeResult.numberOfItems();
    System.out.println("Found " + itemCount + "items in aeResult.");

    // print results
    NSAppleEventDescriptor subDescriptor;

    for(int i = 1; i <= itemCount; i++)
    {
    subDescriptor =
    aeResult.descriptorAtIndex(i);
    System.out.println(" " + subDescriptor.stringValue());
    }
    }
    else {
    System.out.println("aeResult was null.");
    }
    // status
    System.out.println("Script run complete."); }
    }

    • Panther problems
      2004-04-14 18:01:03  TToolsSeth [View]

      I'm having the same experience. A script that used to work now takes a really long time. I've discovered that it's related to timeout and that the script will return in 2 * timeout seconds (default timeout is 1 minute, which is why you see the 2 minute duration). If you wrap your script in "with timeout of 10 seconds ... end" it will only take 20 seconds to execute.

      Is there any forum for reporting bugs with the Applescript glue code?