[Jmol-developers] label command with no args

hi all,
Rasmol/Chime allow the 'label' command to be scripted with no args, like th=
is:
select ala
label
both programs use a default label string showing atom, number, group, chain=
(etc). not sure of the exact syntax off the top of my head ,but it's not =
relevant here.
Jmol throws an exception 'bad argument count' when 'label' is called with o=
n args. I would like to change this so Jmol does what R/C do, but I'm stuc=
k. I thought it would be easy but...
I found label() in Eval.java, which starts off like this:
String strLabel =3D (String)statement[1].value;
I thought if I changed it to this:
String strLabel;
if (statement[1].value =3D=3D null)=20
strLabel =3D "[%n]%r.%a";
else=20
String strLabel =3D (String)statement[1].value;
it might work, but it doesn't. obvoiusly some other function is catching t=
he error, but I can't find which one. can anyone point me in the right dir=
ection please?
be gentle; I am only barely Java-compliant. :-)
thanks,
tim
--=20
Timothy Driscoll
molvisions - see, grasp, learn.
<http://www.molvisions.com/&gt;
usa:north carolina:raleigh
"The more I study science, the more I believe in God." - Albert Einstein

Thread view

hi all,
Rasmol/Chime allow the 'label' command to be scripted with no args, like th=
is:
select ala
label
both programs use a default label string showing atom, number, group, chain=
(etc). not sure of the exact syntax off the top of my head ,but it's not =
relevant here.
Jmol throws an exception 'bad argument count' when 'label' is called with o=
n args. I would like to change this so Jmol does what R/C do, but I'm stuc=
k. I thought it would be easy but...
I found label() in Eval.java, which starts off like this:
String strLabel =3D (String)statement[1].value;
I thought if I changed it to this:
String strLabel;
if (statement[1].value =3D=3D null)=20
strLabel =3D "[%n]%r.%a";
else=20
String strLabel =3D (String)statement[1].value;
it might work, but it doesn't. obvoiusly some other function is catching t=
he error, but I can't find which one. can anyone point me in the right dir=
ection please?
be gentle; I am only barely Java-compliant. :-)
thanks,
tim
--=20
Timothy Driscoll
molvisions - see, grasp, learn.
<http://www.molvisions.com/&gt;
usa:north carolina:raleigh
"The more I study science, the more I believe in God." - Albert Einstein

Tim wrote:
> hi all,
>
> Rasmol/Chime allow the 'label' command to be scripted with no args, lik=
e
> this:
>
> select ala
> label
I did not know that.
The documentation with RasMol 2.6b2 is incorrect.
It says:
label <boolean>
The lack of curly braces indictes that it is required, not optional. For
example, one of the forms of ribbons is documented as:
ribbons =7B<boolean>=7D
If that is the way that RasMol/Chime actually operate then we can add
support for the naked form of 'label'.
> both programs use a default label string showing atom, number, group,
> chain (etc). not sure of the exact syntax off the top of my head ,but
> it's not relevant here.
That is already implemented in Jmol, but in order to get it you must say
'label on'
> Jmol throws an exception 'bad argument count' when 'label' is called wi=
th
> on args. I would like to change this so Jmol does what R/C do, but I'm=
> stuck. I thought it would be easy but...
>
> I found label() in Eval.java, which starts off like this:
>
> String strLabel =3D (String)statement=5B1=5D.value;
>
>
> I thought if I changed it to this:
>
> String strLabel;
> if (statement=5B1=5D.value =3D=3D null)
> strLabel =3D =22=5B%n=5D%r.%a=22;
> else
> String strLabel =3D (String)statement=5B1=5D.value;
>
>
> it might work, but it doesn't.
Good attempt. However, if the other function had not been ensuring 1
argument then it would have died with an IndexOutOfBoundsException ...
because statement=5B1=5D would not have existed.
> obvoiusly some other function is catching
> the error, but I can't find which one.
Compiler.java does some primitive argument count checking. It only works
for a few statements because most take a variable number of arguments.
It is driven by a table in Token.java
> can anyone point me in the right
> direction please?
1. open Token.java
2. search for =22label=22 ... with the double quotes
3. the '1' that is on that line means that it requires exactly 1 argument=
change the '1' to say 'onDefault1' ... as with =22hbonds=22. This means t=
hat
the statement requires 1 argument, but takes 'on' as the default if no
arguments are provided.
4. recompile
5. verify
6. check in
> be gentle; I am only barely Java-compliant. :-)
I hope that was painless ;-)
If you can, try to get it done today ... I would like to do another
pre-release on the evening of Mon 30 May 2005.
Miguel

On 2005-05-30 (12:37) Miguel wrote:
>Tim wrote:
>
>>hi all,
>>
>>Rasmol/Chime allow the 'label' command to be scripted with no args,
>>like this:
>>
>>select ala label
>
>I did not know that. The documentation with RasMol 2.6b2 is
>incorrect.
>
>It says:
>label <boolean>
>
>The lack of curly braces indictes that it is required, not optional.
>For example, one of the forms of ribbons is documented as:
>ribbons =3D7B<boolean>=3D7D
>
hi Miguel,
well, I can't verify Rasmol just now but I am almost positive it works with=
out arguments. certainly Chime does.
>
>If that is the way that RasMol/Chime actually operate then we can
>add support for the naked form of 'label'.
>
ok, that would be great.
>>both programs use a default label string showing atom, number,
>>group, chain (etc). not sure of the exact syntax off the top of my
>>head ,but it's not relevant here.
>
>That is already implemented in Jmol, but in order to get it you must
>say 'label on'
>
ah, I should have thought of that.
<snip>
>Compiler.java does some primitive argument count checking. It only
>works for a few statements because most take a variable number of
>arguments.
>
>It is driven by a table in Token.java
>
ah-ha.
<snip helpful step-by-step>
>
>I hope that was painless ;-)
>
inarguably. :-)
>
>If you can, try to get it done today ... I would like to do another
>pre-release on the evening of Mon 30 May 2005.
>
um, ok...but I can't seem to access CVS right now :-( keeps choking on vie=
wer/script. will keep trying.
thanks for the help Miguel,
tim
--=20
Timothy Driscoll
molvisions - see, grasp, learn.
<http://www.molvisions.com/&gt;
usa:north carolina:raleigh
"There are three kinds of death in this world. There's heart death, there's=
brain death, and there's being off the network." - Guy Almes

Tim,
>>If you can, try to get it done today ... I would like to do another
>>pre-release on the evening of Mon 30 May 2005.
>>
> um, ok...but I can't seem to access CVS right now :-( keeps choking on=
> viewer/script. will keep trying.
Any progress?
Miguel