<html dir="ltr"><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">P {
        MARGIN: 0px
}
</style>
<meta name="GENERATOR" content="MSHTML 8.00.7600.16535">
<style id="owaTempEditStyle"></style><style title="owaParaStyle"><!--P {
        MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px
}
--></style>
</head>
<body ocsi="x">
<div style="FONT-FAMILY: Tahoma; DIRECTION: ltr; COLOR: #000000; FONT-SIZE: 13px">
<div></div>
<div dir="ltr"><font color="#000000" size="2" face="Tahoma">Mark,</font></div>
<div dir="ltr"><font size="2" face="tahoma"></font> </div>
<div dir="ltr"><font size="2" face="tahoma">The Windows builds use the Cygwin<a></a> "UNIX" style of paths. So, if you want to go up one directory and then down into another, use the ".." parent directory. The "." directory is the current directory.</font></div>
<div dir="ltr"><font size="2" face="tahoma"></font> </div>
<div dir="ltr"><font size="2" face="tahoma">John Huddleston, PhD</font></div>
<div style="DIRECTION: ltr" id="divRpF374583">
<hr tabindex="-1">
<font color="#000000" size="2" face="Tahoma"><b>From:</b> gradsusr-bounces@gradsusr.org [gradsusr-bounces@gradsusr.org] On Behalf Of Mark Sponsler [msponsler@comcast.net]<br>
<b>Sent:</b> Friday, April 23, 2010 9:39 AM<br>
<b>To:</b> GrADS Users Forum<br>
<b>Subject:</b> Re: [gradsusr] Pass Data via the 'Return' Expression<br>
</font><br>
</div>
<div></div>
<div>
<div style="FONT-FAMILY: Arial; COLOR: #000000; FONT-SIZE: 10pt">
<p>Brian,</p>
<p>Excellent addtional examples. I am using gfsallow right now, and it works fine if the 'b' script is in the same directory as the 'a' script. </p>
<p>But now I'm kinda stuck because I want the b script to be in a different directory. I'm trying to set up a bunch of common scripts in a standalone directory, so they can be accessed from any grads script elswhere on the drive. So pathing is now the issue.</p>
<p> </p>
<p>I'm trying to locate 'script b' using gfspath.</p>
<p> </p>
<p>Say 'script a' is here: c:/grib/a (and executed from that location), and 'script b' (the .gsf script) is here: c:/grib/b</p>
<p> </p>
<p>I can't seem to figure out how to get gfspath to go 'up' one directory, then down into directory b <br>
</p>
<p>I tried </p>
<p><font face="Courier New">rc = gsfpath("./b") but the scripts hangs on the gfspath command.
</font></p>
<p><font face="Courier New"></font> </p>
<p><font face="Courier New">I'm on a Windows build of Grads. </font></p>
<p><br>
</p>
<div><font size="2">Thanks,<br>
Mark</font></div>
<br>
<br>
----- Original Message -----<br>
From: "Brian Doty" <doty@cola.iges.org><br>
To: "GrADS Users Forum" <gradsusr@gradsusr.org><br>
Sent: Thursday, April 22, 2010 7:42:56 PM GMT -08:00 US/Canada Pacific<br>
Subject: Re: [gradsusr] Pass Data via the 'Return' Expression<br>
<br>
The "gsfallow" stuff is usually the better solution, but I will also note that if you have a main script that issues the run command to grads, ie:
<div><br>
</div>
<div><font class="Apple-style-span" size="3" face="'Courier New'"><span style="FONT-SIZE: 13px" class="Apple-style-span">"run myscript.gs "args</span></font></div>
<div><br>
</div>
<div>and if that script returns something via the <font class="Apple-style-span" size="3" face="'Courier New'">
<span style="FONT-SIZE: 13px" class="Apple-style-span">return</span></font> statement, then that string is available to the first script in the
<font class="Apple-style-span" size="3" face="'Courier New'"><span style="FONT-SIZE: 13px" class="Apple-style-span">result </span></font>variable. </div>
<div><br>
</div>
<div>Example:</div>
<div><br>
</div>
<div>script a:</div>
<div><font class="Apple-style-span" size="3" face="'Courier New'"><span style="FONT-SIZE: 13px" class="Apple-style-span"><br>
</span></font></div>
<div><font class="Apple-style-span" size="3" face="'Courier New'"><span style="FONT-SIZE: 13px" class="Apple-style-span">"run b.gs testing"</span></font></div>
<div><font class="Apple-style-span" size="3" face="'Courier New'"><span style="FONT-SIZE: 13px" class="Apple-style-span">say "--->"result"<---"</span></font></div>
<div><br>
</div>
<div>script b:</div>
<div><font class="Apple-style-span" size="3" face="'Courier New'"><span style="FONT-SIZE: 13px" class="Apple-style-span"><br>
</span></font></div>
<div><font class="Apple-style-span" size="3" face="'Courier New'"><span style="FONT-SIZE: 13px" class="Apple-style-span">function b(args)</span></font></div>
<div><font class="Apple-style-span" size="3" face="'Courier New'"><span style="FONT-SIZE: 13px" class="Apple-style-span">return(subwrd(args,1))</span></font></div>
<div><br>
</div>
<div>If you run a.gs from within grads, you should see the following line output:</div>
<div><font class="Apple-style-span" size="3" face="'Courier New'"><span style="FONT-SIZE: 13px" class="Apple-style-span"><br>
</span></font></div>
<div><font class="Apple-style-span" size="3" face="'Courier New'"><span style="FONT-SIZE: 13px" class="Apple-style-span">---->testing<----</span></font></div>
<div><br>
</div>
<div>...Brian</div>
<div><br>
</div>
<div>
<div>
<div>On Apr 21, 2010, at 8:42 PM, Mark Sponsler wrote:</div>
<br>
<blockquote>
<div>Charles,<br>
It works perfectly now. Excellent example you provided. I had previous read the tutorial provided, but never really understood the implications of it all until I saw your example. It makes perfect sense now. Thanks so much for taking the time to help. Would
have never figured it out on my own. <br>
<br>
<div>Thanks again,<br>
Mark</div>
<br>
<br>
----- Original Message -----<br>
From: Charles Seman <br>
To: GrADS Users Forum <br>
Sent: Wed, 21 Apr 2010 23:47:00 +0000 (UTC)<br>
Subject: Re: [gradsusr] Pass Data via the 'Return' Expression<br>
<br>
Hi Mark,<br>
<br>
Please find attached main.gs (calling script) and add1.gsf (GrADS script <br>
function).<br>
<br>
***********************<br>
* Main script<br>
***********************<br>
<br>
rc = gsfallow("on")<br>
<br>
iVal = 1<br>
<br>
say 'iVal = 'iVal<br>
say 'Making Call to GrADS script function "add1"'<br>
<br>
oVal = add1(iVal)<br>
<br>
say 'Call Made - Checking for Answer'<br>
<br>
say 'oVal = 'oVal<br>
<br>
Try using GrADS main script as follows:<br>
<br>
ga-> main.gs<br>
iVal = 1<br>
Making Call to GrADS script function "add1"<br>
input val = 1<br>
new val = 2<br>
Passing Variable Back to Main Script<br>
Call Made - Checking for Answer<br>
oVal = 2<br>
<br>
<br>
in main.gs, a call is made to an external user-defined script function <br>
"add1.gsf" (<a href="http://grads.iges.org/grads/gadoc/gsf.html" target="_blank">http://grads.iges.org/grads/gadoc/gsf.html</a>) and can be <br>
called from *outside* of main.gs because of "rc = gsfallow("on")" in <br>
main.gs and because of the suffix "gsf" for "add1.gsf"...<br>
<br>
first, if only the line "rc = gsfallow("on")" is commented out (add1.gsf <br>
exists), the result (you can try this):<br>
ga-> main.gs<br>
iVal = 1<br>
Making Call to GrADS script function "add1"<br>
Function not found: add1 <br>
Error occurred on line 12<br>
In file main.gs<br>
<br>
next, if the line "rc = gsfallow("on")" is active, but add1.gsf is <br>
renamed to add1.gs (you can try this):<br>
ga-> main.gs<br>
iVal = 1<br>
Making Call to GrADS script function "add1"<br>
Function not found: add1 <br>
Error occurred on line 12<br>
In file main.gs<br>
<br>
Hope this helps,<br>
Chuck<br>
<br>
Mark Sponsler wrote:<br>
><br>
> Hi Chales,<br>
> I took a look at the script you referenced and was similar to others <br>
> I've seen where the main script and the subscripts are all encased in <br>
> the same physical file. What I'm trying to accomplish is to have a <br>
> main script in one directory and a bunch of scripts of comomonly used <br>
> routines in a separate directory. The idea is to have the main script <br>
> call one of the common routines, then have the common routine pass <br>
> some variable data back to the main script for additional processing. <br>
><br>
> Below is a simple example with both scripts in the same directory. The <br>
> problem is the value _val1 never gets returned to the main script. <br>
> I'm using Grads 1.9 on WinXP.<br>
><br>
> Any thoughts or ideas would be welcome!<br>
><br>
> ***********************<br>
> * Main script<br>
> ***********************<br>
><br>
> rc = gsfallow("on")<br>
><br>
> val = 1<br>
><br>
> say 'Val = 'val<br>
> say 'Making Call to Test_Call'<br>
><br>
> 'run test_call.gs 1'<br>
><br>
> say 'Call Made - Checking for Answer'<br>
><br>
> say 'New val = '_val1<br>
><br>
><br>
> Here's the called script<br>
> ************************<br>
> * Seconadry Script<br>
> ************************<br>
> function main (args)<br>
> if (args='')<br>
> say 'No argument provided. Argument must be a value 1-10'<br>
> return<br>
> else<br>
> val = subwrd(args,1)<br>
> endif<br>
><br>
> say 'Val = 'val<br>
><br>
> _val1 = (val + 1)<br>
><br>
> say 'New Val = '_val1<br>
><br>
> say 'Passing Variable Back to Main Script'<br>
><br>
> return(_val1)<br>
><br>
> Thanks,<br>
> Mark<br>
><br>
><br>
> ----- Original Message -----<br>
> From: Charles Seman<br>
> To: GrADS Users Forum<br>
> Sent: Tue, 20 Apr 2010 21:21:12 +0000 (UTC)<br>
> Subject: Re: [gradsusr] Pass Data via the 'Return' Expression<br>
><br>
> 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" target="_blank">http://www.iges.org/grads/gadoc/library</a><br>
> <a href="about:blank" target="_blank">ftp://grads.iges.org/grads/scripts/plotskew.gs</a><br>
><br>
> Hope this helps,<br>
> Chuck<br>
><br>
> Mark Sponsler wrote:<br>
> ><br>
> > I have a script that calls a second script (and passes some arguments<br>
> > to it). That works fine. I'm trying to get the second script to return<br>
> > some data back to the first script, but am having difficulty. I use<br>
> > the 'return' command to have the second script return control back the<br>
> > first script, but cannot seem to get any variable data to pass with<br>
> > it. It seems this is possible per the Grads documentation:<br>
> ><br>
> > <br>
> ><br>
> > <br>
> ><br>
> > To return from a function, use the |return| command:<br>
> ><br>
> > |return /expression/|<br>
> ><br>
> > The |/expression/| is optional; if not provided, a NULL string<br>
> > will be returned. (A null string is: '') The result of the<br>
> > function is the result of the expression specified on the return<br>
> > command.<br>
> ><br>
> > <br>
> ><br>
> > In the second script, the last line is:<br>
> ><br>
> > <br>
> ><br>
> > return val1<br>
> ><br>
> > <br>
> ><br>
> > Where val1 is a variable string<br>
> ><br>
> > <br>
> ><br>
> > Just can't seem to get the first script to read the contents of<br>
> > val1. Could always write the data to a file, but am looking for<br>
> > something a little more elegant.<br>
> ><br>
> ><br>
> > <br>
> ><br>
> > Any help would be appreciated,<br>
> > Mark<br>
> ><br>
> > ------------------------------------------------------------------------<br>
> ><br>
> > _______________________________________________<br>
> > gradsusr mailing list<br>
> > <a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
> > <a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
> > <br>
><br>
> -- <br>
><br>
> Please note that <a href="mailto:Charles.Seman@noaa.gov">Charles.Seman@noaa.gov</a> should be considered my NOAA<br>
> email address, not <a href="mailto:cjs@gfdl.noaa.gov">cjs@gfdl.noaa.gov</a>.<br>
><br>
> ********************************************************************<br>
> Charles Seman <a href="mailto:Charles.Seman@noaa.gov">Charles.Seman@noaa.gov</a><br>
> U.S. Department of Commerce / NOAA / OAR<br>
> Geophysical Fluid Dynamics Laboratory voice: (609) 452-6547<br>
> 201 Forrestal Road fax: (609) 987-5063<br>
> Princeton, NJ 08540-6649 <a href="http://www.gfdl.noaa.gov/~cjs/" target="_blank">http://www.gfdl.noaa.gov/~cjs/</a><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>
> <a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
> <a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
> ------------------------------------------------------------------------<br>
><br>
> _______________________________________________<br>
> gradsusr mailing list<br>
> <a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
> <a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
> <br>
<br>
-- <br>
<br>
Please note that <a href="mailto:Charles.Seman@noaa.gov">Charles.Seman@noaa.gov</a> should be considered my NOAA<br>
email address, not <a href="mailto:cjs@gfdl.noaa.gov">cjs@gfdl.noaa.gov</a>.<br>
<br>
********************************************************************<br>
Charles Seman <a href="mailto:Charles.Seman@noaa.gov">Charles.Seman@noaa.gov</a><br>
U.S. Department of Commerce / NOAA / OAR<br>
Geophysical Fluid Dynamics Laboratory voice: (609) 452-6547<br>
201 Forrestal Road fax: (609) 987-5063<br>
Princeton, NJ 08540-6649 <a href="http://www.gfdl.noaa.gov/~cjs/" target="_blank">http://www.gfdl.noaa.gov/~cjs/</a><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>
<a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
http://gradsusr.org/mailman/listinfo/gradsusr<br>
</div>
</blockquote>
</div>
<br>
</div>
<br>
_______________________________________________ gradsusr mailing list gradsusr@gradsusr.org http://gradsusr.org/mailman/listinfo/gradsusr
</div>
</div>
</div>
</body>
</html>