<div dir="ltr"><div><div><div>Hi Sebastian,<br><br></div>As you point out, it can't be done directly with variables and $..$ notation. But it would work if your variables were made to be attributes of some "hosting variable":<br><br>ncl 0> hostVar = True<br>ncl 1> hostVar@ALLindex = 3.14159<br>ncl 2> user_selection = "ALL"<br>ncl 3> dynvar = user_selection + "index"<br>ncl 4> var1 = hostVar@$dynvar$<br>ncl 5> 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"><<a href="mailto:sebastian.milinski@mpimet.mpg.de" target="_blank">sebastian.milinski@mpimet.mpg.de</a>></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 = "ALL"<br>
dynvar = user_selection + "index"<br>
var1 = dynvar ; <- 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>