VMD-L Mailing List
From: Arthur Pereira da Fonseca (arthurpfonseca3k_at_hotmail.com)
Date: Sun Jun 12 2022 - 11:54:27 CDT
- Next message: Geist, Norman: "Re: simple script question"
- Previous message: Leonardo Palmieri: "Different results in using GUI or script Timelime"
- In reply to: michaelmorgan937_at_gmail.com: "simple script question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Hello Michael
In tcl you can use brackets as a command substitution. When you call it, it will be replaced by the result of running the script inside the brackets. You can read more about it here: https://urldefense.com/v3/__https://stackoverflow.com/a/63336858/11972447__;!!DZ3fjg!7j4K2qGcfUwjN0Hfuo8g4CL45KDPJjGpbMVr_Y1k8CqBhiJ1USg3tAG3WdfSUGGC5k5Vjznxu3J93qh9W5lcQm9beYiUEQ$
It`s the same logic as you did with the set sel command:
set sel [atomselect top all]
You’re using the result of the atomselect function to create a variable sel. You just have to do the same thing to create your variable list_A:
set list_A [$sel get radius]
This will create a variable with the result from the expression $sel get radius. And now you use it as you wish:
$sel set radius $list_A
De: michaelmorgan937_at_gmail.com<mailto:michaelmorgan937_at_gmail.com>
Enviado:sexta-feira, 10 de junho de 2022 16:10
Para: vmd-l_at_ks.uiuc.edu<mailto:vmd-l_at_ks.uiuc.edu>
Assunto: vmd-l: simple script question
Dear all,
Can anyone instruct me how to pass a list from a result?
For example,
set sel [atomselect top all]
$sel get radius
will return a list of all atoms’ radius, let’s call it list_A.
Now if I want to pass this list back (just for practice purpose):
$sel set radius list_A
How to pass result of “$sel get radius” to a variable list_A and use it in “set radius” command?
Thank you very much.
Michael M.
- Next message: Geist, Norman: "Re: simple script question"
- Previous message: Leonardo Palmieri: "Different results in using GUI or script Timelime"
- In reply to: michaelmorgan937_at_gmail.com: "simple script question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]