<div dir="ltr">Any variable declared/defined outside of the scope of a procedure/function/outer-begin-end block will be in the global scope. It has to have been defined before it is ever referenced. <br><div><br> a = 3.14<br><br>procedure foo()<br>begin<br> print("foo sees a: " + a)<br>end<br><br>procedure bar()<br>begin<br> print("bar sees a: " + a) <br>end<br><br>begin<br> print("main sees a: " + a)<br> foo()<br> bar()<br>end<br>(0) main sees a: 3.14<br>(0) foo sees a: 3.14<br>(0) bar sees a: 3.14<br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 2, 2018 at 1:43 PM, Jon Meyer <span dir="ltr"><<a href="mailto:jonathan.meyer@aggiemail.usu.edu" target="_blank">jonathan.meyer@aggiemail.usu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hello,</div><div><br></div><div>I'm hoping to streamline some automated cron job NCL code I've written that could greatly benefit from having global variables set that the main program and functions/procedures can all share..mainly, the directory system I'm navigating around so I don't have to hardcode or pass directory strings in and out of variables.</div><div><br></div><div>I know NCL isn't directly able to do global variables, but some reading into this shows the ability to take advantage of NCL's scoping to essentially create global variables.<br></div><div><br></div><div>I've looked through past ncl-talk threads but the discussion on how to accomplish this is light other than it can be done, and the scoping discussion on the ncl page isn't as visually helpful on how to do this. After a few attempts, I've failed trying to follow the basic example included in the few ncl-talk threads from the past so I'm hoping someone can elaborate or provide an example for setting string (or other type) variables to be accessible to functions/procedures called from main code where the strings are set.<br></div><div><br></div><div>Any help of time is appreciated.<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888"><div><br>-- <br><div class="m_-5696537245400187505gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr">Jonathan D.D. Meyer, Ph.D.<div>Utah State University<br><div>Department of Plants, Soils & Climate</div><div>Utah Climate Center</div></div></div></div></div></div>
</div></font></span></div>
<br>______________________________<wbr>_________________<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/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>