From: <ha...@us...> - 2009-07-08 14:22:22
|
Revision: 11192 http://jmol.svn.sourceforge.net/jmol/?rev=11192&view=rev Author: hansonr Date: 2009-07-08 14:03:15 +0000 (Wed, 08 Jul 2009) Log Message: ----------- version=11.7.47_dev arrays by ref # bug fix: arrays passed to functions by reference do not update if size is increased # new feature: by passing an array to a function, you can make that variable # return a value -- any value, not just an array: # function test(a) { # a = "new value" # } # b = [] # test(b) # print b ==> "new value" # Modified Paths: -------------- trunk/Jmol/src/org/jmol/shape/UccageRenderer.java trunk/Jmol/src/org/jmol/viewer/Jmol.properties trunk/Jmol/src/org/jmol/viewer/ScriptFunction.java trunk/Jmol/src/org/jmol/viewer/ScriptVariable.java Modified: trunk/Jmol/src/org/jmol/shape/UccageRenderer.java =================================================================== --- trunk/Jmol/src/org/jmol/shape/UccageRenderer.java 2009-07-08 03:39:56 UTC (rev 11191) +++ trunk/Jmol/src/org/jmol/shape/UccageRenderer.java 2009-07-08 14:03:15 UTC (rev 11192) @@ -99,7 +99,7 @@ int y = lineheight; String spaceGroup = symmetry.getSpaceGroupName(); - if (spaceGroup != null) { + if (spaceGroup != null & !spaceGroup.equals("-- [--]")) { y += lineheight; g3d.drawStringNoSlab(spaceGroup, null, x, y, 0); } Modified: trunk/Jmol/src/org/jmol/viewer/Jmol.properties =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2009-07-08 03:39:56 UTC (rev 11191) +++ trunk/Jmol/src/org/jmol/viewer/Jmol.properties 2009-07-08 14:03:15 UTC (rev 11192) @@ -3,11 +3,22 @@ version=11.7.47_dev +# bug fix: arrays passed to functions by reference do not update if size is increased +# new feature: by passing an array to a function, you can make that variable +# return a value -- any value, not just an array: +# function test(a) { +# a = "new value" +# } +# b = [] +# test(b) +# print b ==> "new value" +# +# bug fix: spacegroup "-- [--]" displayed when load command option SPACEGROUP is used # bug fix: mol2 reader not properly allowing override of CRYSIN unit cell record # bug fix: %r not correct label # bug fix: quaternionFrame default now "p" # bug fix: quaternion difference off by one group -# bug fix: show functions not working +# bug fix: show FUNCTIONS not working # bug fix: draw picking in multimodel context causes null pointer exception # new feature: within("HELIX"), within("SHEET") -- helix and sheet, but not ends # new feature: all.bin(f0, f1, df) -- binning of data to give an integer array of counts Modified: trunk/Jmol/src/org/jmol/viewer/ScriptFunction.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ScriptFunction.java 2009-07-08 03:39:56 UTC (rev 11191) +++ trunk/Jmol/src/org/jmol/viewer/ScriptFunction.java 2009-07-08 14:03:15 UTC (rev 11192) @@ -67,18 +67,33 @@ int nParams = (params == null ? 0 : params.size()); for (int i = names.size(); --i >= 0;) { String name = ((String) names.get(i)).toLowerCase(); - contextVariables.put(name, (i < nParameters && i < nParams ? - new ScriptVariable((ScriptVariable) params.get(i)) - : (new ScriptVariable(Token.string, "")).setName(name))); - - -// contextVariables.put(name, (i < nParameters && i < nParams ? -// new ScriptVariable().set((ScriptVariable) params.get(i)) -// : (new ScriptVariable(Token.string, "")).setName(name))); + ScriptVariable var = (i < nParameters && i < nParams ? + (ScriptVariable) params.get(i) : null); + if (var != null && var.tok != Token.list) + var = new ScriptVariable(var); + contextVariables.put(name, (var == null ? + (new ScriptVariable(Token.string, "")).setName(name) : var)); } contextVariables.put("_retval", ScriptVariable.intVariable(0)); } + public void unsetVariables(Hashtable contextVariables, Vector params) { + // set list values in case they have changed. + int nParams = (params == null ? 0 : params.size()); + int nNames = names.size(); + if (nParams == 0 || nNames == 0) + return; + for (int i = 0; i < nNames && i < nParams; i++) { + ScriptVariable global = (ScriptVariable) params.get(i); + if (global.tok != Token.list) + continue; + ScriptVariable local = (ScriptVariable) contextVariables.get(((String) names.get(i)).toLowerCase()); + if (local.tok != Token.list) + continue; + global.value = local.value; + } + } + void addVariable(String name, boolean isParameter) { variables.put(name, name); names.add(name); Modified: trunk/Jmol/src/org/jmol/viewer/ScriptVariable.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ScriptVariable.java 2009-07-08 03:39:56 UTC (rev 11191) +++ trunk/Jmol/src/org/jmol/viewer/ScriptVariable.java 2009-07-08 14:03:15 UTC (rev 11192) @@ -502,7 +502,10 @@ } static ScriptVariable selectItem(ScriptVariable var) { - if (var.index != Integer.MAX_VALUE) + // pass bitsets created by the select() or for() commands + // and all arrays by reference + if (var.index != Integer.MAX_VALUE || + var.tok == list && var.intValue == Integer.MAX_VALUE) return var; return (ScriptVariable) selectItem(var, Integer.MIN_VALUE); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |