<div dir="ltr">So are you referencing the ListIndex function?<div><br></div><div><a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/ListIndex.shtml">https://www.ncl.ucar.edu/Document/Functions/Built-in/ListIndex.shtml</a><br>

<div><br></div><div>From the list section of the manual... <a href="https://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclVariables.shtml#ListVariables">https://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclVariables.shtml#ListVariables</a></div>

<div><br></div><div>I usually try to construct lists with ListPush and ListPop...this is more consistent with how lists are intended to work in other languages (I know it from Java, but I&#39;m sure there are others) where they are intended to host any number of data types, but the *order* of the items is what is relevant. You declare the list to be &quot;first-in, first out&quot; or &quot;last-in, first out&quot; and push things in or pop things out of the list, which will return items as intended. You can also get the index and pull it out as an object from an array would as well, although this is not as simple.</div>

</div><div><br></div><div>Personally, I&#39;ve had a few issues with how variables are treated once pushed/popped from a list last time I tried to use the feature, but I can&#39;t recall what the specific issue was off the top of my head. I&#39;d be curious as well to hear more from those who work with lists in NCL more often.</div>

<div><br></div><div><br></div><div>Kyle</div></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr">----------------------------------------<div>Kyle S. Griffin</div><div>Department of Atmospheric and Oceanic Sciences</div>

<div>University of Wisconsin - Madison</div><div>Room 1421</div><div>1225 W Dayton St, Madison, WI 53706</div><div>Email: <a href="mailto:ksgriffin2@wisc.edu" target="_blank">ksgriffin2@wisc.edu</a></div></div></div>
<br><br><div class="gmail_quote">On Mon, Aug 4, 2014 at 4:26 PM, Brammer, Alan P <span dir="ltr">&lt;<a href="mailto:abrammer@albany.edu" target="_blank">abrammer@albany.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Dear NCL talk,<br>
<br>
I never really utilise lists in NCL as I struggle with how they work.  Hopefully this mundane example can help clarify my desires and maybe find a solution.  Or maybe I’m trying to use them in a way they were not meant.<br>


<br>
I have a function “list_test” as below, and in my script I call that and depending on the argument will get a return list back, that all works great.  My question is how do I get say variable &quot;x&quot; out of the returned list.  I can assume its location in the list but that seems risky and unfriendly for development.<br>


<br>
Can I get an array of the variables names within a list so I can then pull “x” out using ListIndex or something similar.<br>
Is there a listIndex where I pass the variable name instead of the variable.<br>
Do I have to attach a list of names and index locations to the list so I know where things are in it?<br>
<br>
<br>
As always these example scripts are exemplifying much more complicated code therefore hard coding the answer isn’t really the solution I want.<br>
<br>
<br>
Thanks in advance,<br>
<br>
Alan.<br>
<br>
<br>
<br>
<br>
undef(&quot;list_test&quot;)<br>
function list_test(a:logical)<br>
local k, x, y, x, retlist<br>
begin<br>
  if(a)<br>
      x = fspan(0,10, 11)<br>
      y = fspan(100,120,11)   ;  just random arrays of numbers.<br>
      z = ispan(0,100,1)<br>
      retlist = [/ x, y, z /]<br>
  else<br>
      k  = ispan(10,15, 1)<br>
      x = fspan(10,20, 11)<br>
      y = fspan(200,220,11)<br>
      retlist = [/ k, x, y /]<br>
  end if<br>
<br>
  return(retlist)<br>
end<br>
<br>
<br>
<br>
<br>
begin<br>
<br>
firstlist = list_test(True)<br>
print(firstlist)<br>
<br>
; xind = ind( firstlist .eq. “x”   )   ;;; is there some way for this to work?  firstlist@variable ? ?<br>
<br>
secondlist = list_test(False)<br>
print(secondlist)<br>
<br>
; xind = ind( secondlist .eq. “x”   )   ;;;<br>
<br>
end<br>
<br>
_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div><br></div>