<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Here's a function I use to format the grads date and time for various plot annotation (titles, etc):</div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">* &nbsp;Function to reformat the GrADS date/time into something</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">* &nbsp;more readable</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;"><br></span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">function mydate</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp;'query time'</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp;sres = subwrd(result,3)</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp;wd = subwrd(result,6)</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp;i = 1</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp;while (substr(sres,i,1)!='Z')</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp; &nbsp;i = i + 1</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp;endwhile</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp;hour = substr(sres,1,i)</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp;isav = i</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp;i = i + 1</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp;while (substr(sres,i,1)&gt;='0' &amp; substr(sres,i,1)&lt;='9')</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp; &nbsp;i = i + 1</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp;endwhile</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp;day = substr(sres,isav+1,i-isav-1)</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp;month = substr(sres,i,3)</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp;year = substr(sres,i+3,4)</span></font></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">&nbsp;&nbsp;return (hour' 'wd', 'month' 'day', 'year)</span></font></div><div><font class="Apple-style-span" face="'Courier New'"><br></font></div><div>As you can see, it returns some stuff there at the end.</div><div><br></div><div>When you invoke this function from elsewhere, there are a couple of ways to use the returned string. &nbsp;One way is to assign it to a variable:</div><div><br></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">dtlabel = mydate()</span></font></div><div><br></div><div>Another way is to just use it inline, for example:</div><div><br></div><div><font class="Apple-style-span" face="'Courier New'" size="3"><span class="Apple-style-span" style="font-size: 13px;">'draw string 0.1 0.2 12Hr Forecast Valid 'mydate()</span></font></div><div><br></div><div>There is also a way to share variables between script functions by using a "global" variable, which is any variable name that starts with an underscore. &nbsp;Those variables are shared by all the functions in the script file. &nbsp;I tend to avoid using them (because it can be hard later to figure out where they are getting set vs where they are getting used) -- but they do come in handy at times... Brian&nbsp;</div><br><div><div>On Apr 20, 2010, at 5:21 PM, Charles Seman wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Mark,<br><br>Don't know if you have resolved this yet, but Bob Hart's "plotskew.gs" <br>script has examples of what it appears that you want to do:<br><a href="http://www.iges.org/grads/gadoc/library">http://www.iges.org/grads/gadoc/library</a><br>ftp://grads.iges.org/grads/scripts/plotskew.gs<br><br>Hope this helps,<br>Chuck<br><br>Mark Sponsler wrote:<br><blockquote type="cite"><br></blockquote><blockquote type="cite">I have a script that calls a second script (and passes some arguments <br></blockquote><blockquote type="cite">to it). That works fine. I'm trying to get the second script to return <br></blockquote><blockquote type="cite">some data back to the first script, but am having difficulty. &nbsp;I use <br></blockquote><blockquote type="cite">the 'return' command to have the second script return control back the <br></blockquote><blockquote type="cite">first script, but cannot seem to get any variable data to pass with <br></blockquote><blockquote type="cite">it. It seems this is possible per the Grads documentation:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">To return from a function, use the |return| command:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;|return /expression/|<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;The |/expression/| is optional; if not provided, a NULL string<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;will be returned. (A null string is: '') The result of the<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;function is the result of the expression specified on the return<br></blockquote><blockquote type="cite"> &nbsp;&nbsp;&nbsp;command.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">In the second script, the last line is:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">return val1<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Where val1 is a variable string<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Just can't seem to get the first script to read the contents of <br></blockquote><blockquote type="cite">val1. Could always write the data to a file, but am looking for <br></blockquote><blockquote type="cite">something a little more elegant.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Any help would be appreciated,<br></blockquote><blockquote type="cite">Mark<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">------------------------------------------------------------------------<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">_______________________________________________<br></blockquote><blockquote type="cite">gradsusr mailing list<br></blockquote><blockquote type="cite">gradsusr@gradsusr.org<br></blockquote><blockquote type="cite">http://gradsusr.org/mailman/listinfo/gradsusr<br></blockquote><blockquote type="cite"><br></blockquote><br>-- <br><br>Please note that Charles.Seman@noaa.gov should be considered my NOAA<br>email address, not cjs@gfdl.noaa.gov.<br><br>********************************************************************<br> Charles Seman &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Charles.Seman@noaa.gov<br> U.S. Department of Commerce / NOAA / OAR<br> Geophysical Fluid Dynamics Laboratory &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;voice: (609) 452-6547<br> 201 Forrestal Road &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fax: (609) 987-5063<br> Princeton, NJ &nbsp;08540-6649 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http://www.gfdl.noaa.gov/~cjs/<br>********************************************************************<br><br>"The contents of this message are mine personally and do not reflect any<br>official or unofficial position of the United States Federal Government,<br>the United States Department of Commerce, or NOAA."<br><br>_______________________________________________<br>gradsusr mailing list<br>gradsusr@gradsusr.org<br>http://gradsusr.org/mailman/listinfo/gradsusr<br></div></blockquote></div><br></body></html>