From: Schreiner Eduard (eschrein_at_ks.uiuc.edu)
Date: Tue Jul 22 2008 - 11:40:13 CDT

Hi Katherine,

On Jul 22, 2008, at 11:03 AM, Katherine Parra wrote:

> Dear VMD community:
> How do I correctly use the vecsub command to evaluate previously
> defined variables?
>
> This is part of my script:
>
> set pta [atomselect top "index 1856"]
> set ptb [atomselect top "index 1835"]
> set ptc [atomselect top "index 724"]
> set all [atomselect top all]
>
> set acoor [lindex{$pta get {x y z}}0]
> set bcoor [lindex{$ptb get {x y z}}0]
>

I think it should rather be

set acoor [lindex [ $pta get {x y z}] 0 ]

So, not curly braces but [ .. ] in order to get the coordinates.
This will evaluate the expression within [ ... ].

I think that { ... } is used to store lists, not for evaluating
commands, at least in this context

works for me

eddi

> set absub [vecsub $bcoor $acoor]
> set abmag [veclength $absub]
>
> set ccoor [lindex{$ptc get {x y z}}0]
>
> set acsub [vecsub $ccoor $acoor]
> set acmag [veclength $acsub]
>
>
> everytime I try to run this script I get an error message: vecsub:
> non-numeric in first argument
>
> I was trying without using the lindex command first but then I read
> that somebody else asked you about this and he used the lindex
> command and it worked, but know I am using the lindex command and
> It is not working at all.
> What could I do?
>
> Thanks in advance.
> KP