OK, I see the problem. The _modelNumber is associated with the frame change,
not the model loading, and that happens after all this callback stuff. I've
added two additional parameters to the callback:
* myLoadStructCallback(appID, fullPathName, fileName, modelName,
errorMsg, ptLoad, priorCurrentModelNumberDotted,
lastLoadedModelNumberDotted)
ptLoad = 3 for successful file loading
priorCurrentModelNumberDotted = "3.1" for example, or "1.1 - 3.31" if a
whole range of models is framed
lastLoadedModelNumberDotted = the file.model number for the very last model
loaded.
Will upload tomorrow.
* {}
*
* ptLoad == FILE_STATUS_NOT_LOADED == -1 ptLoad == FILE_STATUS_ZAPPED ==
0
* ptLoad == FILE_STATUS_CREATING_MODELSET == 2 ptLoad ==
* FILE_STATUS_MODELSET_CREATED == 3 ptLoad == FILE_STATUS_MODELS_DELETED
== 5
*
* Only -1 (error loading), 0 (zapped), and 3 (model set created) messages
are
* passed on to the callback function.
*
On Mon, Jul 12, 2010 at 12:53 PM, Alexander Rose <
[email protected]> wrote:
> Hi,
>
> thanks Angel, Bob.
>
> I tried it, but (not a show stopper) it only works when I do a
> setTimeout(...), e.g.
>
>
> function myLoadStructCallback(...){
> console.log( jmolEvaluate("_modelNumber"), jmolEvaluate("_lastFrame") );
> // prints the frame id shown before the load
> setTimeout( function(){
> console.log( jmolEvaluate("_modelNumber"),
> jmolEvaluate("_lastFrame") ); // print the new frame id though the timeout
> needed may vary depending on machine and browser...
> }, 500)
> }
>
>
> Alex
>
> ----- Ursprüngliche Mail -----
> > Von: "Robert Hanson" <[email protected]>
> > An: [email protected]
> > Gesendet: Montag, 12. Juli 2010 17:17:35
> > Betreff: Re: [Jmol-users] how to get the jmol file id for a model just
> loaded into an applet
> > yes -- Angel has it. The variable is _modelNumber.
> >
> > In JavaScript:
> >
> > var currentModel = "" + jmolEvaluate("_modelNumber")
> >
> > should do it. This should be a string, not a number, since "3.10" is
> > different from "3.1". Remember, though, that multiple models can be
> > loaded when a file is loaded. I think that's why it's not part of the
> > parameter set. Of course, this only applies to the "append" method --
> > any straight load command will result in "1.1" for the current model
> > number.
> >
> > Bob
> >
> >
> >
> >
> > On Mon, Jul 12, 2010 at 8:47 AM, Alexander Rose <
> > [email protected] > wrote:
> >
> >
> > Hi,
> >
> > I would like to get the file id/number (that is file from the
> > file.model notation, e.g. "file1.model1) of a model just loaded into
> > an Jmol applet. I hoped 'set LoadStructCallback "someJsFunction"'
> > would rescue me, but LoadStructCallback gives only the params
> > 'appletName, fullPathName, fileName, modelName, ptLoad'. Is there
> > another way to get the file id from a just loaded model? Otherwise I'
> > like to request a new feature, that is the file id as a new param for
> > LoadStructCallback. I can imagine to keep track of the loaded and
> > deleted models in javascript alone by using dedicated loading/deleting
> > javascript wrappers, but that smells error prone.
> >
> > Alex
> >
> >
> ------------------------------------------------------------------------------
> > This SF.net email is sponsored by Sprint
> > What will you do first with EVO, the first 4G phone?
> > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> > _______________________________________________
> > Jmol-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/jmol-users
> >
> >
> >
> > --
> > Robert M. Hanson
> > Professor of Chemistry
> > St. Olaf College
> > 1520 St. Olaf Ave.
> > Northfield, MN 55057
> > http://www.stolaf.edu/people/hansonr
> > phone: 507-786-3107
> >
> >
> > If nature does not answer first what we want,
> > it is better to take what answer we get.
> >
> > -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
> >
> >
> ------------------------------------------------------------------------------
> > This SF.net email is sponsored by Sprint
> > What will you do first with EVO, the first 4G phone?
> > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> > _______________________________________________
> > Jmol-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/jmol-users
>
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> _______________________________________________
> Jmol-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
--
Robert M. Hanson
Professor of Chemistry
St. Olaf College
1520 St. Olaf Ave.
Northfield, MN 55057
http://www.stolaf.edu/people/hansonr
phone: 507-786-3107
If nature does not answer first what we want,
it is better to take what answer we get.
-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users