Haven't found any documentation regarding how to do it, but is there any way to input values into the script as command line arguments, such that they can be used (like the variable _arguments_ array, when invoking a Jmol function) in the script? I mean in a call like this:
$ ./jmol.sh --nodisplay --script ~/.jmol/macros/myscript.spt
Interesting idea. An alternative would be to assign your variables in a script prior to the -s script call using
-J "v1='test';v2='now'" -s myscript.spt
and then use those variables in the script.
Not quite the same, I realize.
Bob
It does the job, but yes, the variables names are needed when calling the script.
Last edit: Federico 2023-05-08
Hi Federico
You are right, but anyway how would you set the script file for your intended command line parameters? I think there will always be the need to provide data in a variable.
How about using an array variable?
-J "arg = ['oxygen', 'pink']" -s myscript.spt
and then in myscript.spt use
arg[1] etc arg[2] etc , like this:
select @{arg[1]}; color @{arg[2]};
Something like the positional scheme in bash would make it. Your array variable is what I had in mind, but in the end you need to reserve
argfor such purpose in your scripts (needs documentation when you share them). @hansonr's solution with the_argumentsvariable is similar, only that now this variable is the one for all. This feature will help in batch processing.Last edit: Federico 2023-05-09
Jmol.___JmolVersion="16.1.14" // (swingJS) also 16.1.13 (legacy)
new feature: Jmol application -A --scriptarguments flag
example:
jmol -s "test.spt" -A "2,3,4"
where test.spt is
result is