On Sun, Jan 4, 2009 at 3:57 AM, Timothy Pratley
<timothyprat...@gmail.com> wrote:
>
>> I suspect that *command-line-arguments* would have "myapp.clj" as the
>> 0th element in the
>> clj myapp.clj
>> Can't test right now though sorry.
>
> I tested this and it does work for me. If it does not work for you is
> most likely in your clj script or bat file. I noticed on the wiki the
> incorrect advice was given:
>    java  -cp %CLOJURE_JAR%;%CONTRIB_JAR% clojure.lang.Script %1
>
> I've updated the wiki with the correct usage:
>    java  -cp %CLOJURE_JAR%;%CONTRIB_JAR% clojure.lang.Script %1 -- %*
>
> Check your script for the -- between script name and arglist. Note
> that %* includes %1.
>
> script-test.clj:
> (if *command-line-args*
>  (println "SCRIPT")
>  (println "REPL"))
>
> C:\java>clj script-test.clj
> SCRIPT
>
> C:\java>clj
> Clojure
> user=> (load-file "script-test.clj")
> REPL
> nil

Thanks! I've got it working this way now. My script defines a "main"
function. At the bottom of the script I do this:

; Only run the application automatically if run as a script,
; not if loaded in a REPL with load-file.
(if *command-line-args* (main))

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to