Re: queries about "Tclforces" utility in NAMD

From: harish vashisth (harish.vashisth_at_gmail.com)
Date: Fri May 25 2012 - 09:57:43 CDT

Dear Axel,
    This was really helpful. Just having those commands defined as
procedures in the beginning of my tcl script helps. In fact, when i
"source" NAMD's "vectors.tcl" script by adding those routines on top, I am
able to make use of all vector commands as well as transformation matrix
inside calcforces. Thanks again.

Jerome---i saw your 2004 fix in "vectors.tcl" to get around "lassign"...i
was trying to use that when Axel suggested this more elegant way to
activate these commands...thanks a lot.

Regards,
-Harish

On Fri, May 25, 2012 at 6:54 AM, Axel Kohlmeyer <akohlmey_at_gmail.com> wrote:

> On Fri, May 25, 2012 at 3:48 AM, Jérôme Hénin <jhenin_at_ifr88.cnrs-mrs.fr>
> wrote:
>
> [...]
>
> >> (c) it also appears that NAMD's tcl-interpreter does not understand tcl
> >> commands: lassign, lvarpop...or am I missing something?..I have tried
> these
> >> things on a serial binary of version 2.8/2.9..
> >
> > These commands are relatively recent additions to Tcl. If you manage
> > to compile NAMD linked to a recent Tcl implementation (ie version
> > 8.5), you'll have access to them.
>
> those were previously part of TclX and can be easily emulated in Tcl
> script.
> this is what VMD uses in one of its startup scripts.
>
> # TclX commands we still use in VMD
> proc lassign { listvar args } {
> set i 0
> foreach var $args {
> upvar $var x
> set x [lindex $listvar $i]
> incr i
> }
> return [lrange $listvar $i end]
> }
>
> proc lvarpush { listvar var } {
> upvar $listvar x
> set x [list $var $x]
> }
>
> proc lvarpop { var } {
> upvar $var x
> set retval [lindex $x 0]
> set x [lrange $x 1 end]
> return $retval
> }
>
> axel.
>
> >
> > Best,
> > Jerome
> >
>
>
>
> --
> Dr. Axel Kohlmeyer
> akohlmey_at_gmail.com http://goo.gl/1wk0
>
> College of Science and Technology
> Temple University, Philadelphia PA, USA.
>

This archive was generated by hypermail 2.1.6 : Mon Dec 31 2012 - 23:21:33 CST