VMD-L Mailing List
From: Bennion, Brian (Bennion1_at_llnl.gov)
Date: Fri Jul 05 2013 - 17:27:28 CDT
- Next message: Josh Vermaas: "Re: manipulation of atomselections"
- Previous message: Axel Kohlmeyer: "Re: manipulation of atomselections"
- In reply to: Axel Kohlmeyer: "Re: manipulation of atomselections"
- Next in thread: Josh Vermaas: "Re: manipulation of atomselections"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
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
Brian
________________________________________
From: Axel Kohlmeyer [akohlmey_at_gmail.com]
Sent: Friday, July 05, 2013 3:00 PM
To: Bennion, Brian
Cc: vmd-l_at_ks.uiuc.edu
Subject: Re: vmd-l: manipulation of atomselections
On Fri, Jul 5, 2013 at 10:54 PM, Bennion, Brian <Bennion1_at_llnl.gov> 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] {
or
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.)
axel.
> Brian
>
-- Dr. Axel Kohlmeyer akohlmey_at_gmail.com http://goo.gl/1wk0 International Centre for Theoretical Physics, Trieste. Italy.
- Next message: Josh Vermaas: "Re: manipulation of atomselections"
- Previous message: Axel Kohlmeyer: "Re: manipulation of atomselections"
- In reply to: Axel Kohlmeyer: "Re: manipulation of atomselections"
- Next in thread: Josh Vermaas: "Re: manipulation of atomselections"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]