Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

majorp

macrumors 6502
Original poster
Nov 28, 2005
314
0
UK !!!
I have textmate and want the java "on run and compile" script to open terminal and compile and run the code.

this is what i have

Code:
osascript <<EOF
    tell application "Terminal" 
        activate
	   try
           close windows
        end try
      do script "cd '$TM_DIRECTORY'; javac '${TM_FILENAME%}'"
      do script "cd '$TM_DIRECTORY'; java '${TM_FILENAME%.java}'"
    end tell
EOF

works fine however it opens two terminal windows.

i don't know applescript and am just learning java.

how do I make both of the "do script" run in the same window?!

thanks
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,630
Western US
how do I make both of the "do script" run in the same window?!

thanks
Just combine them with a semicolon, since they need to be run in sequence anyway.

do script "cd '$TM_DIRECTORY'; javac '${TM_FILENAME%}'; java '${TM_FILENAME%.java}'"

EDIT: oops, beat me to it :p
 

majorp

macrumors 6502
Original poster
Nov 28, 2005
314
0
UK !!!
Perhaps try

Code:
do script "cd '$TM_DIRECTORY'; javac '${TM_FILENAME%}'; java '${TM_FILENAME%.java}'"

?

worked wonderfully! but now I have another unforeseen problem.

when there is an error in the java code terminal throws an error but still runs the compiled java program from the previous compile making it confusing to whether you have a problem or not.

I need some sort of "on error pause" type of command although i'm not sure if this exists?
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,630
Western US
worked wonderfully! but now I have another unforeseen problem.

when there is an error in the java code terminal throws an error but still runs the compiled java program from the previous compile making it confusing to whether you have a problem or not.

I need some sort of "on error pause" type of command although i'm not sure if this exists?
Try using &&. I think that's supposed to continue only if the prior command succeeds:

do script "cd '$TM_DIRECTORY'; javac '${TM_FILENAME%}' && java '${TM_FILENAME%.java}'"

You may need a more sophisticated script though. Maybe it cleans up the intermittent files and reports the error or something.
 

majorp

macrumors 6502
Original poster
Nov 28, 2005
314
0
UK !!!
Try using &&. I think that's supposed to continue only if the prior command succeeds:

do script "cd '$TM_DIRECTORY'; javac '${TM_FILENAME%}' && java '${TM_FILENAME%.java}'"

You may need a more sophisticated script though. Maybe it cleans up the intermittent files and reports the error or something.

Perfect!

Thanks guys/gals for your time :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.