ajoso
August 7, 2006, 4:12pm
#1
Related to the batch runner in code exchange section
http://bbs.applescript.net/viewtopic.php?id=17922
I tried to run the applescript file which Orso posted in java.
import com.apple.cocoa.foundation.;
import com.apple.cocoa.application. ;
import com.apple.cocoa.application.NSApplication;
//import NSApplication;
public class partB {
public static void main(String[] args)
{
NSApplication.sharedApplication();
String script = "global VWfileTypes \n"
+"set VWfileTypes to {\"MC6d\", \"MC7d\", \"MC8d\", \"MC9d\", \"DO11\", \"DO12\"} \n"
+"set aVWscript to readFile((choose file with prompt \"Choose a VectorScript file \" of type \"TEXT\") as text) \n"
+"set theChosenFiles to choose file with prompt \"Choose one or more vectorWorks files \" of type VWfileTypes with multiple selections allowed without invisibles \n"
+"launch application \"VectorWorks\" \n"
+"set theProcessedFiles to {return} \n"
+"repeat with aVWfile in the theChosenFiles \n"
+"runTheScript(aVWfile, aVWscript) \n"
+"set end of theProcessedFiles to name of (info for aVWfile) & return \n"
+"end repeat \n"
+"display dialog \"Processed files: \" & theProcessedFiles as text \n"
+"on runTheScript(theVWfile, theVSscript) \n"
+"tell application \"VectorWorks\" \n"
+"open theVWfile \n"
+"ignoring application responses \n"
+"DoScript theVSscript \n"
+"tell application \"System Events\" \n"
+"tell process \"VectorWorks\" \n"
+"set frontmost to true \n"
+"delay 1 \n"
+"key code 36 \n"
+"end tell \n"
+"end tell \n"
+"end ignoring \n"
+"close document 1 saving yes \n"
+"end tell \n"
+"end runTheScript \n";
NSAppleScript myScript = new NSAppleScript(script);
NSMutableDictionary errors = new NSMutableDictionary();
System.out.println("Yay AppleScript!");
}
}
I tried to run your applescript batch runner from java. But it doesn’t work.
I hope someone can let me know, what I do wrong.
Thanks in advance
orso
August 11, 2006, 5:58am
#2
Ajoso, I’m sorry. I have no knowledge of Java. I cannot say why it doesn’t work there. Did you try to load the VS from a text file instead of hard coding it with all chars excapes? Does it work thus?
Orso