BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar
mzimmers
Community Trekker

can a .jsl file accept arguments?

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.

0 Kudos
7 REPLIES 7
Jeff_Perkinson
Community Manager Community Manager

Re: can a .jsl file accept arguments?

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

The technique is outlined well in an earlier thread.

-Jeff

-Jeff
mpz
mpz
Community Trekker

Re: can a .jsl file accept arguments?

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.

0 Kudos
pmroz
Super User

Re: can a .jsl file accept arguments?

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
mpz
Community Trekker

Re: can a .jsl file accept arguments?

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?

0 Kudos
pmroz
Super User

Re: can a .jsl file accept arguments?

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

mpz
mpz
Community Trekker

Re: can a .jsl file accept arguments?

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

0 Kudos
mpz
mpz
Community Trekker

Re: can a .jsl file accept arguments?

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?

0 Kudos