From: Jonathan G. <gu...@uw...> - 2009-12-18 16:21:22
|
Otis, Thanks for the example. However, I'm mystified as to the difference between using a message call back to get the state string and my use of jmolGetPropertyAsString...They should give the same result. Have you ever used your method with an inline set of data? My method works fine if that part of the script is deleted. I'm pretty convinced the issue is CR/LF stuff. The inline data parser uses line breaks to differentiate the different pieces of data. The rest of the script parser separates statements with a semi- colon. I am also still checking some things that might relate to " marks, but don't think this is a problem as " marks work in the rest of the transferred script. Jonathan On Dec 18, 2009, at 8:16 AM, jmo...@li... wrote: > Date: Fri, 18 Dec 2009 08:16:32 -0600 > From: Otis Rothenberger <ot...@ch...> > Subject: Re: [Jmol-users] Need help passing a state script form one > applet to another via javascript... > To: jmo...@li... > Message-ID: > <daf...@ma...> > Content-Type: text/plain; charset=ISO-8859-1 > > Jonathan- > >> Any ideas? >> > > I had exactly the same problem. I finally used the following approach > to "copy/paste" state from one applet to another in Jmol 11.9.9. I do > not use jmol.js, so some of the function calls may seem strange to > you. Nevertheless, I think that the basic concept below is readable. > One Note: Some time is needed between "copy" and "paste." I use user > lag time in making a transfer manually. For automatic transfer, you > may need to use a JavaScript setTimeout delay between "copy" and > "paste." > > Use show state to pass state as a message: > > function copyMol() { > if (feedbackFlag) { feedback(r[9]); } // Relevant to my page > only. > evalRasmol("select *"); // My script eval function. Its name is > obviously historic! > evalRasmol("show state;delay 2;"); > mepsData["tempHold"] = mepsData[jmol1]; // Relevant to my page > only. > } > > Use message call back function to put state info into global > variable jmolVar1. > Use a variable - not hidden field. Hidden fields gave me problems - > probably CR/LF issues. > They may be hidden, but they seem to insert platform specific line > info: > > function processMessage(appNum, messageString, indexNum) { > if (messageString.indexOf("function _setWindowState() {") > -1) { > jmolVar1 = messageString + ""; } > } > > Put state info in new Jmol applet: > > function pasteMol() { > if (feedbackFlag) { feedback(r[9]); } // Relevant to my page only. > evalRasmol("select *"); > evalRasmol(jmolVar1); > } > > Best Regards > Otis > > -- > Otis Rothenberger > http://chemagic.org Dr. Jonathan H. Gutow Chemistry Department gu...@uw... UW-Oshkosh Office:920-424-1326 800 Algoma Boulevard FAX:920-424-2042 Oshkosh, WI 54901 http://www.uwosh.edu/facstaff/gutow |