On 12/08/2015 03:28 AM, Robert Hanson wrote: > The problem is that these commands actually go in and change settings, not > just the current selection. I suppose the following would do it: > > function displayModel(atoms, mode) { > var a = {selected} > select @atoms > switch (mode) { > case "add": > display add selected > break > case "remove": > display remove selected > break > default: > if (selectAllModels) { > display selected > } else { > set selectAllModels true > display displayed and modelIndex!=_modelIndex or selected > set selectAllModels false > } > break > } > select @a > } > > function hideModel(atoms, mode) { > var a = {selected} > select @atoms > switch (mode) { > case "add": > display remove selected > break > case "remove": > display add selected > break > default: > if (selectAllModels) { > hide selected > } else { > set selectAllModels true > hide hidden and modelIndex!=_modelIndex or selected > set selectAllModels false > } > break > } > select @a > } > > Just a few coding comments: > Thank you for the functions and the comments, Bob.
>> >> ----- 'display' command substitution ---------------- >> function getFileNumberList(atomBitset) { >> if (atomBitset.type != "bitset") { >> atomBitset = {visible}; >> } > > > You can use _arguments.count here: > > if (!_arguments) atomBitset = {visible} > > var fileNumberInfo = atomBitset.file.all.count(); >> var fileNumberList = []; >> >> if (fileNumberInfo.type == "array") { >> for (var i from [1, fileNumberInfo.size]) { >> var fileNumber = fileNumberInfo[i].[1]; >> fileNumberList.push(fileNumber); >> } >> } >> return fileNumberList; >> } >> > > not sure I see the need for the above > Q: Is there a simpler way to get all first array elements out of an array of arrays? Q: Or did you just mean that using '_modelIndex/modelIndex' would be easier? ( As I said earlier, 'file' reflects more properly what I want to achieve than 'modelIndex'.) > > > >> var atomExpressionUpperCase = ("" + atomExpression) % 9999; # >> convert to upper case >> > > This isn't really necessary; for historical reasons, Jmol "==" testing is > not case-sensitive. If you want it to be, you need to use LIKE instead of > "==" > Q: And the same is true for 'case' in 'switch' statements, as the 'displayModel' function above suggests? > >> if (atomExpressionUpperCase == "ADD" || atomExpressionUpperCase == >> "REMOVE") { >> print "ERROR: no atom expression provided in call of 'display' >> command or keyword '" + atomExpressionUpperCase + "' provided as second >> parameter instead of first"; >> } else if (atomExpressionUpperCase == "BONDS") { >> display BONDS; >> } else { >> if (oneParameter == false) { >> > > here I would use > > if (keyword) { > > var keywordUpperCase = ("" + keyword) % 9999; # convert to upper >> case >> if (keywordUpperCase == "ADD" || kewordUpperCase == "REMOVE") { >> atomExpression = keywordUpperCase + " " + atomExpression; >> display @atomExpression; >> > > I don't see how that would work; > > Q: Does that mean that multiple parameters cannot be supplied to a function in a single variable and it must have been 'display @keyword @atomExpression' or 'dummy=script("display " + atomExpression)'? Or did you mean something else? Regards, Rolf -- Rolf Huehne Postdoc Leibniz Institute on Aging - Fritz Lipmann Institute (FLI) Beutenbergstrasse 11 07745 Jena, Germany Phone: +49 3641 65 6205 Fax: +49 3641 65 6210 E-Mail: rhue...@leibniz-fli.de Website: http://www.leibniz-fli.de Scientific Director: Prof. Dr. K. Lenhard Rudolph Head of Administration: Dr. Daniele Barthel Chairman of Board of Trustees: Burkhard Zinner VAT No: DE 153 925 464 Register of Associations: No. 230296, Amtsgericht Jena Tax Number: 162/141/08228 ------------------------------------------------------------------------------ Go from Idea to Many App Stores Faster with Intel(R) XDK Give your users amazing mobile app experiences with Intel(R) XDK. Use one codebase in this all-in-one HTML5 development environment. Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs. http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140 _______________________________________________ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users