From: John Stone (johns_at_ks.uiuc.edu)
Date: Fri Apr 20 2007 - 12:02:14 CDT

Preeda,
  It works fine for me (I just took the script as you
had it in your email, but fixed the one wrapped line of code,
the "same residue as..." selection).

Cheers,
  John Stone
  vmd_at_ks.uiuc.edu

On Sat, Apr 21, 2007 at 12:04:09AM +0900, preeda wrote:
> Dear John and other VMD users,
>
> Now I am trying to test using a trace function.
> I just tried to test a example that written on VMD web
> http://www.ks.uiuc.edu/Research/vmd/current/ug/node144.html
>
> I saved the following script in a file "test.tcl" on VMD main folder
>
> proc mol_weight {} {
> # use the picked atom's index and molecule id
> global vmd_pick_atom vmd_pick_mol
> set sel [atomselect $vmd_pick_mol "same residue as index
> $vmd_pick_atom"]
> set mass 0
> foreach m [$sel get mass] {
> set mass [expr $mass + $m]
> }
> # get residue name and id
> set atom [atomselect $vmd_pick_mol "index $vmd_pick_atom"]
> lassign [$atom get {resname resid}] resname resid
> # print the result
> puts "Mass of $resname $resid = $mass"
> }
>
> proc mol_weight_trace_fctn {args} {
> mol_weight
> }
>
> trace variable vmd_pick_atom w mol_weight_trace_fctn
>
> Then I typed "source test.tcl" in VMD TkConsole
> There is no message like "Mass of *** *** = ***" appears when I pick an
> atom in OpenGL Display window
>
> So do u know what I did something wrong? I am sorry if this is a simple
> problem.
> Your help will be greatly appreciated.
>
> Best Regards,
>
> Preeda

-- 
NIH Resource for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
Email: johns_at_ks.uiuc.edu                 Phone: 217-244-3349
  WWW: http://www.ks.uiuc.edu/~johns/      Fax: 217-244-6078