I’m trying to write a script which will use the Terminal to compile and run a java file written in the coder’s text editor called Smultron. The problem I’m having with my script is that it works only with files saved on the desktop or if the enclosing folder is open. I need to get the path to the open Smultron document whether or not the enclosing folder is open.
tell application "Smultron"
activate
set theFile to the name of the front window
set theClass to the first word of theFile
end tell
try
tell application "Finder" to set theFolder to (folder of the front window) as string
set thePath to POSIX path of theFolder
on error
set thePath to "~/Desktop"
end try
tell application "Terminal"
activate
do script with command "cd " & thePath & ";clear; javac " & theFile & "; java " & theClass & "; echo"
activate
end tell