On 13 Nov 2009 at 20:28, Jonathan Gutow wrote:

> if (! nameSuffix)
>        nameSuffix = appletCount;
> considers nameSuffix = 0 as True. 

You mean it considers nameSuffix as false when it is zero, hence !nameSuffix as 
true.
That's regular javascript. There is also the issue of "undefined", but seems 
not to apply in 
the case of a parameter/argument in a function.


> The following change appears to  
> make it work properly:
> if (nameSuffix == null)
>        nameSuffix = appletCount;

Sounds reasonable to me, Jonathan, but I tested and found a glitch:
if the parameter is given as an empty string, "", your new code fails.
I think it can be achieved using

if (nameSuffix==null || ""+nameSuffix=="") 

that directs to auto-assign
- no parameter passed
- empty string parameter passed
but skips auto-assign for 
- 0
- "0"


I'm not sure if the empty string will really reach _jmolApplet() since it will 
be passed along 
from user-front functions like jmolApplet(), but I think it's safe to include 
this test in any 
case.
I had to add the empty quotes in the second half of the test because otherwise 
zero still 
evaluates equal to empty string.

I think we can modify Jmol.js in this sense.



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Jmol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers

Reply via email to