From: Bennion, Brian (
Date: Fri Jul 05 2013 - 17:27:28 CDT

Thank you Axel.

I substituted numbers for the archaic variable names that were originally in my code. I didn't want to complicate the email, but it raised flags anyway.

list generation seems to be my achilles heel

all works now. Thank you

From: Axel Kohlmeyer []
Sent: Friday, July 05, 2013 3:00 PM
To: Bennion, Brian
Subject: Re: vmd-l: manipulation of atomselections

On Fri, Jul 5, 2013 at 10:54 PM, Bennion, Brian <> wrote:
> Hello,
> At some level this question is a tcl and vmd syntax issue.

this is entirely Tcl.

> set 1 [atomselect $loop1 "resname OBDN and (name O34 or name O35)"]
> set 2 [atomselect $loop1 " resname I61 and name O9"]
> set 3 [atomselect $loop1 " resname hlo0 and (name O14 or name O17)"]

using numbers as variable names is usually not a great idea. but anyway.

> foreach x { 1 2 3 } {

this is not referencing the variables from above but just the plain
numbers. if you want a list of the atom selections, you can use

foreach x [list $1 $2 $3] {


foreach x "$1 $2 $3" {

another option is to skip the variable definition and just do

set list [atomselect ...]
lappend list [atomselect...]
lappend list [atomselect...]

and then:

foreach x $list {

> if { [$x list ] != {} } {
> do something
> }
> }
> The error is: invalid command name "1"

yes. because that is the value you assign to x.

> I am just trying to check to make sure the atomselection actually contains
> something before I operate on it.

now on that subject, you can also improve your test and simply use

 if { [$x num] > 0} {

(well, this is a VMD thingy after all.)

> Brian

Dr. Axel Kohlmeyer
International Centre for Theoretical Physics, Trieste. Italy.