Thanks, Bob, for this.

Can you clarify the purpose of  “true”, as in:

var x = load(“filename”, TRUE)

I would like to learn when is it necessary.  Your example uses “true” for .png 
but not for .cif.   The help page shows the TRUE flag showing up elsewhere, as 
in the function
x = y.split("", TRUE)

I am uncertain of how to use “true" properly.

Matt

On Aug 22, 2015, at 12:51 AM, Robert Hanson 
<hans...@stolaf.edu<mailto:hans...@stolaf.edu>> wrote:

http://sourceforge.net/projects/jmol/files/Jmol-beta/Jmol%2014.3/Jmol%2014.3.16/Jmol-14.3.16_2015.08.21-binary.zip/download

Jmol.___JmolVersion="14.3.16_2015.08.21"

new feature: load var x
  -- same as load "@x"
  -- similar in syntax to write var x t.png
  -- example:

  var x = load("quartz.cif")
  load var x {1 1 1}

bug fix: creating and running and saving binary hash from PNGJ fails
  -- allows creating an associative binary array from a PNGJ file
     then modifying it and loading that variable
     then saving it as a new PNGJ file
  -- initial PNGJ file is not necessary if binary array x is created first
  -- example:

      var x = load("test.png",true)
      load "@x"
      write test2.png as PNGJ

bug fix: hover callback is not supposed to be stopped with HOVER OFF
bug fix: atom.sx and atom.sy<http://atom.sy/> and atom.sz<http://atom.sz/> 
report incorrectly when antialiasing is on
bug fix: write VAR x "test.png" creates a ZIP file instead of a PNGJ file when 
x is from load("test.png",true)
bug fix: write test.png as PNGJ (without initial quotes) fails


​comments:

OK, that wasn't so bad. Thank you, Rolf, for suggesting this. It is a nice 
complement to write var x.

This completes the capability for Jmol or JSmol to read, modify,  load, and 
save PNGJ and ZIP files.

1) Reading a PNGJ or ZIP file into a variable using TRUE to indicate binary 
file:

x = load("test.png", TRUE)
# [x is a binary associative array]
print x.keys
$_BINARY_$
JmolManifest.txt
Jmol_version_14.3.16_2015.08.21__2015-08-21_09.06
_IMAGE_
http___cactus.nci.nih.gov_chemical_structure_caffeine_file_format_sdf_get3d_True
state.spt

where "$_BINARY_$" indicates that entries are byte arrays.
and _IMAGE_ is the PNG image, indicating this is from a PNGJ file

2) modifying that file if desired

# coerce to string:
s = "" + x["state.spt"]
# ...modify here...
# replace state.spt in PNGJ file data
x["state.spt"] = s

# Or, for example, adding an image that will be used for an optional background 
image

x = load("test.png",true)
# a standard binary associative array will have just two keys, $BINARY$ and 
_DATA_
# only PNGJ has _IMAGE_

x["z.jpg"] = load("z.jpg",true)._DATA_
print x.keys
write var x "test3.png"
....sometime later...
load "test3.png"
background image "test3.png|z.jpg"


3) write to a new PNGJ file

write var x "test2.png"

4) optionally, load that PNGJ data directly from the variable, perhaps to see 
that the modifications are correct:

load var x

(new syntax; same as older load "@x")

Note that both of these syntaxes work with standard string file data and can be 
extended with options:

x = load("quartz.cif")
load var x {1 1 1}

Bob



------------------------------------------------------------------------------
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net<mailto:Jmol-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/jmol-users

------------------------------------------------------------------------------
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to