Save the following as script file in some folder (say c:\my folder).
>From a CMD prompt session in that folder call the script like this:
c:\my folder>"c:\program files\j602\bin\j.exe" -jijx runscript.ijs
"argument one" argument-two
Now check your temp folder for the files test.txt & test2.txt.
======runscript.ijs=====================
NB. call from folder containing runscript.ijs with:
NB.
load 'files'
'hello world' fwrites jpath '~temp/test.txt'
(>ARGV_j_) fwrites jpath '~temp/test2.txt'
args=: 3}. ARGV_j_
('only extra args',LF) fappends jpath '~temp/test2.txt'
(> args) fappends jpath '~temp/test2.txt'
========end script=======================
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of PackRat
> Sent: Monday, 18 February 2008 08:46
> To: Programming forum
> Subject: [Jprogramming] Beginner question--invoking J with arguments
>
> Thanks again for all the previous help I received here! Now
> that I've
> got a working script, I didn't realize just *how* fast J is: loading,
> sorting, deduping, and comparing two files with around
> 200,000 library
> record numbers each, and then writing out a third file of another
> 80,000 records altogether took only a few seconds! Wow!!
>
> Anyway, because I need to move data between multiple applications, I
> currently use another scripting language (MS VBScript) to send the
> various commands (in my script that I noted above)
> sequentially to a J
> server. (I would prefer to have used AutoIt as my "master" scripting
> language, which is more powerful than VBScript, but AutoIt currently
> seems to have an issue with receiving "variant"-type data
> back from an
> OLE server, such as a J server, so I had to resort to VBScript
> instead.) I thought a useful next step in the process would be to
> invoke J with a particular script (and perhaps arguments,
> too), so that
> my "master" scripting language(s) could have merely a single "shell"-
> like command rather than a series of commands that simulate manually
> typing a script into J.
>
> Similar to what I've noted in other previous messages, as a
> beginner I
> found it extremely difficult to find information along this
> line. The
> "Command Line Parameters" chapter in the "Overview" section of the
> online "User Manual" (Usr) seemed to have what I was looking--with an
> emphasis on "seemed" because I still can't get anything to
> work, hence
> my question. The chapter gave 4 groups of patterns for invoking J in
> various circumstances.
>
> The first pattern group seemed to be the one I wanted (or was I
> wrong??)--here's the final pattern in that group:
> J FN ARGS [J=servername, FN=scriptname, ARGS=0 or more arguments]
>
> Unfortunately, *NO* practical examples were given for any of the
> patterns in any of the groups, except the last (which I'll ask about
> later on). So, lacking any examples, I tried all of the following
> variations (sending the scriptname and the names of the two files for
> the script to handle) and possibly more variations that I've since
> forgotten. I also tried *not* using any arguments, just to see if I
> could get even that much to work.
>
> (1) Windows shortcut target:
>
> "c:\Program Files\j\j.exe c:\Program Files\j\temp\myscript.ijs
> c:\iii1.txt c:\iii2.txt"
>
> "c:\Program Files\j\j.exe c:\Program Files\j\temp\myscript.ijs
> 'c:\iii1.txt' 'c:\iii2.txt'"
>
> "c:\Program Files\j\j.exe 'c:\Program Files\j\temp\myscript.ijs'
> 'c:\iii1.txt' 'c:\iii2.txt'"
>
> "c:\Program Files\j\j.exe c:\Program Files\j\temp\myscript.ijs"
>
> "c:\Program Files\j\j.exe 'c:\Program Files\j\temp\myscript.ijs'"
>
> (2) DOS command line:
>
> c:\Progra~1\j\j.exe c:\Program Files\j\temp\myscript.ijs c:\iii1.txt
> c:\iii2.txt
>
> c:\Progra~1\j\j.exe c:\Program Files\j\temp\myscript.ijs
> 'c:\iii1.txt'
> 'c:\iii2.txt'
>
> c:\Progra~1\j\j.exe 'c:\Program Files\j\temp\myscript.ijs'
> 'c:\iii1.txt' 'c:\iii2.txt'
>
> c:\Progra~1\j\j.exe c:\Program Files\j\temp\myscript.ijs
>
> c:\Progra~1\j\j.exe 'c:\Program Files\j\temp\myscript.ijs'
>
> (I also tried using double quotes instead of single quotes in the DOS
> commands.)
>
> In all cases, Windows/DOS complained and/or failed. (My memory seems
> to indicate that the second last Windows and DOS commands actually
> started J, but then J just sat there waiting for manually-typed
> commands.) As I said, I tried every variation I could think of for
> what the indicated pattern in the User Manual might have
> meant, but to
> no avail.
>
> Just before writing this message, I looked again at the User
> Manual to
> verify the pattern I tried to follow above, and I noted that
> the fourth
> pattern *might* also be close to what I'm looking for, but I have
> questions about it:
>
> The Manual states:
> J -js ARGS - creates verb ARGVERB_z_ from ARGS and runs it
> and has the examples:
> jconsole.exe -js a=.23 b=.3 "echo a*b"
> jconsole.exe -js a=.23 b=.3 "echo a*b" exit
>
> Instead of ARGS being a series of J commands, can it be the name of a
> script to invoke or not? I have a hunch that the answer is "not".
>
> So my question is, how in the world can I invoke the running of a
> script (.ijs file), preferably with arguments that the script could
> utilize internally? In other words, the technique should
> start up a J
> server and "force" a script to run (preferably with the
> possibility of
> arguments to pass to the script). This invocation should be
> able to be
> done as a Windows shortcut (via the "target" command line) or as an
> equivalent "shell"-like command (like a DOS command) in some other
> scripting language. I hope someone can indicate how to do this.
> Thanks!
>
> Harvey
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm