|
|
Re: Shebang lines in Scala scripts
|
Posted: Dec 20, 2007 8:12 PM
|
|
Rob, that's great advice. A little further work is needed (i) to allow command-line parameters to be passed to the Scala script, and (ii) to avoid having to include the .scala suffix in the command.
i) In the Folder Options, File Types tab, with .SCALA selected, hit the Avanced button and in the resulting Edit File Type dialog edit the command for the 'open' action and add %* to it (no quotes) I removed other unnecesary quotes - I don't have any spaces in my path - and my command for the 'open' action is now C:\scala-2.6.1-final\bin\scala.bat %1 %*
ii) add ;.SCALA to your PATHEXT environment variable value.
Now if you have a file args.scala containing the script
args.foreach(println)
you should be able to type
args 1 2 3 4 5
on the command line and see
1 2 3 4 5
as output.
Note that I don't know why the %* works - the documentation that I've been able to find says it refers to all the arguments, but this example suggests that if it comes after %1 it refers to the remaining arguments. I initially used a command line containing "%1" "%2" "%3" etc, which works but can't handle more than 8 arguments (the script file name is in position 1). I took a look at what %* would give, expecting to need to write a different scala.bat file to handle it, but then found it Just Worked.
I tried to use my SCALA_HOME environment variable in the 'open' action definition (to make it easier to move between Scala versions), but, for reasons I don't understand, got an "Access is denied" message. I also tried just using scala in the command (scala %1 %*), since scala.bat is on my path, but this gave me "The specified program could not be found" on trying to save that action definition.
|
|