<div dir="ltr"><div><div><div>Hi Sebastian,<br><br></div>As you point out, it can&#39;t be done directly with variables and $..$ notation.  But it would work if your variables were made to be attributes of some &quot;hosting variable&quot;:<br><br>ncl 0&gt; hostVar = True<br>ncl 1&gt; hostVar@ALLindex = 3.14159<br>ncl 2&gt; user_selection = &quot;ALL&quot;<br>ncl 3&gt; dynvar = user_selection + &quot;index&quot;<br>ncl 4&gt; var1 = hostVar@$dynvar$<br>ncl 5&gt; print(var1)<br><br>Variable: var1<br>Type: float<br>Total Size: 4 bytes<br>            1 values<br>Number of Dimensions: 1<br>Dimensions and sizes:   [1]<br>Coordinates:<br>(0)     3.14159<br><br></div>I hope that helps...<br></div>Rick<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 4, 2016 at 3:30 AM, Milinski, Sebastian <span dir="ltr">&lt;<a href="mailto:sebastian.milinski@mpimet.mpg.de" target="_blank">sebastian.milinski@mpimet.mpg.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I would like to access a variable. The name of the variable to be accessed is created from user input (string) and a suffix (string)<br>
<br>
user_selection = &quot;ALL&quot;<br>
dynvar          = user_selection + &quot;index&quot;<br>
var1                    = dynvar                                        ; &lt;- here I do not want the string ALLindex but the content of ALLindex.<br>
print(var1)<br>
<br>
<br>
The syntax var1 = $dynvar$ does not work. Is there an easy way to do this without several if-statements?<br>
<br>
Thanks,<br>
Sebastian<br>
<br>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>