Subscribe Bookmark RSS Feed

can a .jsl file accept arguments?

mzimmers

Community Trekker

Joined:

Dec 30, 2013

I've looked through the scripting guide, but can't find anything about this (I must be looking in the wrong places).

Is it possible to pass arguments to a .jsl file? For example, if I had a directory full of addins, and wanted to register them, can I write a Windows batch file that will retrieve each addin filename and pass it to a script that will register that addin?

Thanks.

7 REPLIES
Jeff_Perkinson

Community Manager

Joined:

Jun 23, 2011

The best way to do this is to use JSL functions.

The technique is outlined well in an earlier thread.

-Jeff

-Jeff
mpz

Community Trekker

Joined:

Jan 3, 2014

Hey, Jeff -

Thanks for the reference. That solution, while a bit elaborate, seems like a good way to go. Now...what about invoking a .bat file from within a .jsl script, and passing parameters to it?

Thanks again.

pmroz

Super User

Joined:

Jun 23, 2011

You might have to dymanically generate a .bat or .cmd file that calls your main bat file.  Something like this:

p1 = "Hello";

pt = "World";

cmd_file_text = evalinsert("C:\myprogs\mainbatfile ^p1^ ^p2^");

cmd_file = "c:\TEMP\tmprun.cmd";

// Write this file out to a known file location

save text file(cmd_file, cmd_file_text);

// Now execute the command file

open(cmd_file);

mpz

Community Trekker

Joined:

Jan 3, 2014

Thanks, PMroz. As a side question, why is it that EvalInsert isn't listed in the scripting index? I've noticed on other occasions as well that there seem to be quite a few undocumented features that I should know about. Is there a more comprehensive list of functions/features available somewhere?

pmroz

Super User

Joined:

Jun 23, 2011

evalinsert is listed in the scripting index, under Functions / () Utility

mpz

Community Trekker

Joined:

Jan 3, 2014

Right you are...evidently I'm still learning to use the index properly. Thanks for the help.

mpz

Community Trekker

Joined:

Jan 3, 2014

One more (actually, two) question in this general vein, if you please:

The script that I'm modifying uses open() to invoke command files.

1. is this a good way to do this? I ask because the scripting index provides 5 examples of open() but none of them involve command files.

2. how can I get an exit code from the command file? The file in question takes two pathnames as arguments (solved above) and compares their revision dates. I'd like to do something with the exit code like:

1 if the first file is older

0 if the file dates are the same

-1 if the second file is older

And use the exit code within my .jmp script for further action. Any ideas on this one?

Thanks for the assistance.

EDIT: I realize this is a bit off the subject of the original post; should I create a new thread for these questions?