<html><head><style> body {height: 100%; color:#000000; font-size:10pt; font-family:Arial;}</style></head><body>Hi John,<br>Thanks for the information. I had read the instructions on the use of gsfpath before posting to the list. <br><br>I've tried every combination of it as follows with no good result. In the main script I tried:<br>rc = gsfpath("\mark\b")<br>rc = gsfpath("/mark/b")<br>rc = gsfpath("c:\mark\b")<br>rc = gsfpath("c:/mark/b")<br><br>In all instances, the main script hangs on execution of the gsfpath command. It appears to not be able to find the path.<br><br>But if the .gsf file is in the same directory as the main script all works fine (with the gfspath command commented out). Grads just doesn't seems to want to navigate to another directory that is at the same level as the directory that it is being executed out of. I've had problem with pathing in the past and had to use the unmount command to resolve it. <br><br>But no fear, there is another solution.....<br><br>After re-reading Brians suggestions and after having previous limited success with the 'run' command, I have something that works. <br><br>*--Main Script (located in c:/mark/a)--<br>'run c:/mark/b/script2.gs 'var1' 'var2' 'var3<br>answer = result<br> <br>*--Second Script (located at c:/mark/b)-- <br>function script2 (args)<br> vara = subwrd(args,1)<br> varb = subwrd(args,2)<br> varc = subwrd(args,3)<br><br>--process the variables--<br><br>return(final_value)<br><br>One can send the results of script 'b' via the return command, and script 'a' can read those results easily by just reading the result variable and setting it equal to some new variable name. This is all I was trying to accomlish with my original post. <br><br>So the problem is solved. Thanks everyone for all your help. Hopefully this will be useful to other users. <br><br>
<DIV><font size=2>Thanks,<br>Mark</font></DIV><br><br>----- Original Message -----<br>From: John Huddleston <HUDDLESTON@CIRA.COLOSTATE.EDU><br>To: GrADS Users Forum <GRADSUSR@GRADSUSR.ORG><br>Sent: Mon, 26 Apr 2010 14:45:41 +0000 (UTC)<br>Subject: Re: [gradsusr] Pass Data via the 'Return' Expression<br><br>
<DIV class=Section1>
<P class=MsoNormal><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">Good morning Mark,</span></P>
<P class=MsoNormal><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"></span> </P>
<P class=MsoNormal><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">Sorry for the delay, we had nearly three inches of rain followed<br><br>by four inches of snow and I was sequestered at home until today.</span></P>
<P class=MsoNormal><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"></span> </P>
<P class=MsoNormal><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">See <A href="http://www.iges.org/grads/gadoc/gadocindex" target=_blank>http://www.iges.org/grads/gadoc/gadocindex</A><br><br>and click on the gsfpath() indexed item.</span></P>
<P class=MsoNormal><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"></span> </P>
<P class=MsoNormal><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">There are some steps for you to complete; according to the<br><br>instructions on that page.</span></P>
<P class=MsoNormal><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"></span> </P>
<P class=MsoNormal><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">It does appear that those paths must be the full path, e.g. rc =<br><br>gfspath(/home/mark/b /home/mark/a)</span></P>
<P class=MsoNormal><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"></span> </P>
<P class=MsoNormal><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">Here is a snippet from the page</span></P>
<P class=MsoNormal><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"></span> </P>
<P class=MsoNormal style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><span style="COLOR: black">The private path directory list is an optional list that is<br><br>provided via the </span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'">gsfpath</span><span style="COLOR: black"> function: </span></P>
<P class=MsoNormal style="MARGIN-LEFT: 0.5in"><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'">rc = gsfpath("dirlist")</span><span style="COLOR: black"></span></P>
<P class=MsoNormal><span style="COLOR: black">If used, the declaration of the<br><br>private path directory list should appear at the top of the main script just<br><br>underneath the statement enabling the dynamic script loading. </span></P>
<P class=MsoNormal style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><span style="COLOR: black">For example, if our main script "do_eof.gs" is<br><br>executed with the command: </span></P>
<P class=MsoNormal style="MARGIN-LEFT: 0.5in"><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'">run /usr/local/gradslib/do_eof</span><span style="COLOR: black"></span></P>
<P class=MsoNormal style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><span style="COLOR: black">and this script file contains the following lines at the<br><br>front: </span></P>
<P class=MsoNormal style="MARGIN-LEFT: 0.5in"><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'">rc = gsfallow("on")</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'"><br></span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'">rc<br><br>= gsfpath("math1 string2") </span><span style="COLOR: black"></span></P>
<P class=MsoNormal style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><span style="COLOR: black">and the script calls a function </span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'">str_chop</span><span style="COLOR: black"> which is not found in the main script, then the search<br><br>path would be: </span></P>
<ol type=1>
<li class=MsoNormal style="COLOR: black; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1">/usr/local/gradslib/str_chop.gsf
<li class=MsoNormal style="COLOR: black; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1">/usr/local/gradslib/math1/str_chop.gsf
<li class=MsoNormal style="COLOR: black; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto; mso-list: l0 level1 lfo1">/usr/local/gradslib/string2/str_chop.gsf </li>
</ol>
<P class=MsoNormal><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">John</span></P>
<P class=MsoNormal><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"></span> </P>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'">John Huddleston, PhD</span></P></DIV>
<P class=MsoNormal><span style="FONT-SIZE: 11pt; COLOR: #1f497d; FONT-FAMILY: 'Calibri','sans-serif'"></span> </P>
<DIV>
<DIV style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; BORDER-LEFT: medium none; PADDING-TOP: 3pt; BORDER-BOTTOM: medium none">
<P class=MsoNormal><strong><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Tahoma','sans-serif'">From:</span></strong><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Tahoma','sans-serif'"> gradsusr-bounces@gradsusr.org<br><br>[mailto:gradsusr-bounces@gradsusr.org] <strong>On Behalf Of </strong>Mark Sponsler<br><strong>Sent:</strong> Friday, April 23, 2010 2:36 PM<br><strong>To:</strong> GrADS Users Forum<br><strong>Subject:</strong> Re: [gradsusr] Pass Data via the 'Return' Expression</span></P></DIV></DIV>
<P class=MsoNormal> </P>
<DIV>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">John,</span></P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">I<br><br>hate to be a pain but am still having problems.</span></P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"><br><br><br>So if my main script is here: c:/grib/a/main_script.gs and the<br><br>called script is here: c:/grib/b/called.gfs</span></P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'">Then I<br><br>should set gfspath as follows:</span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span></P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'">rc =<br><br>gsfpath("../b") </span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span></P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'">Unfortunately the<br><br>script hangs on the gfspath command. </span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span></P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'">I've<br><br>tried it with both \ and / too. </span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span></P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">Any<br><br>suggestions?</span></P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">Thanks,<br><br><br>Mark</span></P></DIV>
<P class=MsoNormal style="MARGIN-BOTTOM: 12pt"><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"><br><br><br><br>----- Original Message -----<br><br><br>From: "John Huddleston" <Huddleston@cira.colostate.edu><br><br><br>To: "GrADS Users Forum" <gradsusr@gradsusr.org><br><br><br>Sent: Friday, April 23, 2010 11:45:23 AM GMT -08:00 US/Canada Pacific<br><br><br>Subject: Re: [gradsusr] Pass Data via the 'Return' Expression</span></P>
<DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Tahoma','sans-serif'">Mark,</span></P></DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Tahoma','sans-serif'"></span> </P></DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Tahoma','sans-serif'">The Windows builds use the Cygwin "UNIX" style of<br><br>paths. So, if you want to go up one directory and then down into another, use<br><br>the ".." parent directory. The "." directory is the current<br><br>directory.</span></P></DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Tahoma','sans-serif'"></span> </P></DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Tahoma','sans-serif'">John Huddleston, PhD</span></P></DIV>
<DIV id=divRpF374583>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Tahoma','sans-serif'">
<HR align=center width="100%" SIZE=2>
</span></DIV>
<P class=MsoNormal style="MARGIN-BOTTOM: 12pt"><strong><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Tahoma','sans-serif'">From:</span></strong><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Tahoma','sans-serif'"><br><br>gradsusr-bounces@gradsusr.org [gradsusr-bounces@gradsusr.org] On Behalf Of Mark<br><br>Sponsler [msponsler@comcast.net]<br><strong>Sent:</strong> Friday, April 23, 2010 9:39 AM<br><strong>To:</strong> GrADS Users Forum<br><strong>Subject:</strong> Re: [gradsusr] Pass Data via the 'Return' Expression</span></P></DIV>
<DIV>
<DIV>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">Brian,</span></P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">Excellent<br><br>addtional examples. I am using gfsallow right now, and it works fine if<br><br>the 'b' script is in the same directory as the 'a' script. </span></P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">But<br><br>now I'm kinda stuck because I want the b script to be in a different<br><br>directory. I'm trying to set up a bunch of common scripts<br><br>in a standalone directory, so they can be accessed from any grads script<br><br>elswhere on the drive. So pathing is now the issue.</span></P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">I'm<br><br>trying to locate 'script b' using gfspath.</span></P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">Say<br><br>'script a' is here: c:/grib/a (and executed from that<br><br>location), and 'script b' (the .gsf script) is here: c:/grib/b</span></P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">I<br><br>can't seem to figure out how to get gfspath to go 'up' one directory, then down<br><br>into directory b </span></P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">I<br><br>tried </span></P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'">rc =<br><br>gsfpath("./b") but the scripts hangs on the gfspath command. </span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span></P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Courier New'">I'm on<br><br>a Windows build of Grads. </span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span></P>
<P><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">Thanks,<br><br><br>Mark</span></P></DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"><br><br><br><br>----- Original Message -----<br><br><br>From: "Brian Doty" <doty@cola.iges.org><br><br><br>To: "GrADS Users Forum" <gradsusr@gradsusr.org><br><br><br>Sent: Thursday, April 22, 2010 7:42:56 PM GMT -08:00 US/Canada Pacific<br><br><br>Subject: Re: [gradsusr] Pass Data via the 'Return' Expression<br><br><br><br>The "gsfallow" stuff is usually the better solution, but I will also<br><br>note that if you have a main script that issues the run command to grads, ie: </span></P>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P></DIV>
<DIV>
<P class=MsoNormal><span class=apple-style-span><span style="FONT-SIZE: 10pt; FONT-FAMILY: '">"run myscript.gs<br><br>"args</span></span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span></P></DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P></DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">and if that script returns something via the </span><span class=apple-style-span><span style="FONT-SIZE: 10pt; FONT-FAMILY: '">return</span></span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"> statement, then that string is available to<br><br>the first script in the </span><span class=apple-style-span><span style="FONT-SIZE: 10pt; FONT-FAMILY: '">result </span></span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">variable. </span></P></DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P></DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">Example:</span></P></DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P></DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">script a:</span></P></DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P></DIV>
<DIV>
<P class=MsoNormal><span class=apple-style-span><span style="FONT-SIZE: 10pt; FONT-FAMILY: '">"run b.gs testing"</span></span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span></P></DIV>
<DIV>
<P class=MsoNormal><span class=apple-style-span><span style="FONT-SIZE: 10pt; FONT-FAMILY: '">say<br><br>"--->"result"<---"</span></span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span></P></DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P></DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">script b:</span></P></DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P></DIV>
<DIV>
<P class=MsoNormal><span class=apple-style-span><span style="FONT-SIZE: 10pt; FONT-FAMILY: '">function b(args)</span></span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span></P></DIV>
<DIV>
<P class=MsoNormal><span class=apple-style-span><span style="FONT-SIZE: 10pt; FONT-FAMILY: '">return(subwrd(args,1))</span></span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span></P></DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P></DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">If you run a.gs from within grads, you should see the following<br><br>line output:</span></P></DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P></DIV>
<DIV>
<P class=MsoNormal><span class=apple-style-span><span style="FONT-SIZE: 10pt; FONT-FAMILY: '">---->testing<----</span></span><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span></P></DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P></DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">...Brian</span></P></DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P></DIV>
<DIV>
<DIV>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">On Apr 21, 2010, at 8:42 PM, Mark Sponsler wrote:</span></P></DIV>
<blockquote style="MARGIN-TOP: 5pt; MARGIN-BOTTOM: 5pt">
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P>
<DIV>
<P class=MsoNormal style="MARGIN-BOTTOM: 12pt"><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">Charles,<br><br><br>It works perfectly now. Excellent example you provided. I had previous<br><br>read the tutorial provided, but never really understood the implications of it<br><br>all until I saw your example. It makes perfect sense now. <br><br>Thanks so much for taking the time to help. Would have never<br><br>figured it out on my own. </span></P>
<DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'">Thanks again,<br><br><br>Mark</span></P></DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"><br><br><br><br>----- Original Message -----<br><br><br>From: Charles Seman <br><br><br>To: GrADS Users Forum <br><br><br>Sent: Wed, 21 Apr 2010 23:47:00 +0000 (UTC)<br><br><br>Subject: Re: [gradsusr] Pass Data via the 'Return' Expression<br><br><br><br>Hi Mark,<br><br><br><br>Please find attached main.gs (calling script) and add1.gsf (GrADS script <br><br><br>function).<br><br><br><br>***********************<br><br><br>* Main script<br><br><br>***********************<br><br><br><br>rc = gsfallow("on")<br><br><br><br>iVal = 1<br><br><br><br> say 'iVal = 'iVal<br><br><br> say 'Making Call to GrADS script function "add1"'<br><br><br><br>oVal = add1(iVal)<br><br><br><br> say 'Call Made - Checking for Answer'<br><br><br><br> say 'oVal = 'oVal<br><br><br><br>Try using GrADS main script as follows:<br><br><br><br>ga-> main.gs<br><br><br>iVal = 1<br><br><br>Making Call to GrADS script function "add1"<br><br><br>input val = 1<br><br><br>new val = 2<br><br><br>Passing Variable Back to Main Script<br><br><br>Call Made - Checking for Answer<br><br><br>oVal = 2<br><br><br><br><br>in main.gs, a call is made to an external user-defined script function <br><br><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<br><br>be <br><br><br>called from *outside* of main.gs because of "rc =<br><br>gsfallow("on")" in <br><br><br>main.gs and because of the suffix "gsf" for "add1.gsf"...<br><br><br><br>first, if only the line "rc = gsfallow("on")" is commented<br><br>out (add1.gsf <br><br><br>exists), the result (you can try this):<br><br><br>ga-> main.gs<br><br><br>iVal = 1<br><br><br>Making Call to GrADS script function "add1"<br><br><br>Function not found:<br><br>add1 <br><br><br> Error occurred on line 12<br><br><br> In file main.gs<br><br><br><br>next, if the line "rc = gsfallow("on")" is active, but<br><br>add1.gsf is <br><br><br>renamed to add1.gs (you can try this):<br><br><br>ga-> main.gs<br><br><br>iVal = 1<br><br><br>Making Call to GrADS script function "add1"<br><br><br>Function not found:<br><br>add1 <br><br><br> Error occurred on line 12<br><br><br> In file main.gs<br><br><br><br>Hope this helps,<br><br><br>Chuck<br><br><br><br>Mark Sponsler wrote:<br><br><br>><br><br><br>> Hi Chales,<br><br><br>> I took a look at the script you referenced and was similar to others <br><br><br>> I've seen where the main script and the subscripts are all encased<br><br>in <br><br><br>> the same physical file. What I'm trying to accomplish is to<br><br>have a <br><br><br>> main script in one directory and a bunch of scripts of comomonly<br><br>used <br><br><br>> routines in a separate directory. The idea is to have the main<br><br>script <br><br><br>> call one of the common routines, then have the common routine pass <br><br><br>> some variable data back to the main script for additional<br><br>processing. <br><br><br>><br><br><br>> Below is a simple example with both scripts in the same directory.<br><br>The <br><br><br>> problem is the value _val1 never gets returned to<br><br>the main script. <br><br><br>> I'm using Grads 1.9 on WinXP.<br><br><br>><br><br><br>> Any thoughts or ideas would be welcome!<br><br><br>><br><br><br>> ***********************<br><br><br>> * Main script<br><br><br>> ***********************<br><br><br>><br><br><br>> rc = gsfallow("on")<br><br><br>><br><br><br>> val = 1<br><br><br>><br><br><br>> say 'Val = 'val<br><br><br>> say 'Making Call to Test_Call'<br><br><br>><br><br><br>> 'run test_call.gs 1'<br><br><br>><br><br><br>> say 'Call Made - Checking for Answer'<br><br><br>><br><br><br>> say 'New val = '_val1<br><br><br>><br><br><br>><br><br><br>> Here's the called script<br><br><br>> ************************<br><br><br>> * Seconadry Script<br><br><br>> ************************<br><br><br>> function main (args)<br><br><br>> if (args='')<br><br><br>> say 'No argument provided. Argument must be a value<br><br>1-10'<br><br><br>> return<br><br><br>> else<br><br><br>> val = subwrd(args,1)<br><br><br>> endif<br><br><br>><br><br><br>> say 'Val = 'val<br><br><br>><br><br><br>> _val1 = (val + 1)<br><br><br>><br><br><br>> say 'New Val = '_val1<br><br><br>><br><br><br>> say 'Passing Variable Back to Main Script'<br><br><br>><br><br><br>> return(_val1)<br><br><br>><br><br><br>> Thanks,<br><br><br>> Mark<br><br><br>><br><br><br>><br><br><br>> ----- Original Message -----<br><br><br>> From: Charles Seman<br><br><br>> To: GrADS Users Forum<br><br><br>> Sent: Tue, 20 Apr 2010 21:21:12 +0000 (UTC)<br><br><br>> Subject: Re: [gradsusr] Pass Data via the 'Return' Expression<br><br><br>><br><br><br>> Mark,<br><br><br>><br><br><br>> Don't know if you have resolved this yet, but Bob Hart's<br><br>"plotskew.gs"<br><br><br>> script has examples of what it appears that you want to do:<br><br><br>> <A href="http://www.iges.org/grads/gadoc/library" target=_blank>http://www.iges.org/grads/gadoc/library</A><br><br><br>> <A href="about:blank" target=_blank>ftp://grads.iges.org/grads/scripts/plotskew.gs</A><br><br><br>><br><br><br>> Hope this helps,<br><br><br>> Chuck<br><br><br>><br><br><br>> Mark Sponsler wrote:<br><br><br>> ><br><br><br>> > I have a script that calls a second script (and passes some arguments<br><br><br>> > to it). That works fine. I'm trying to get the second script to<br><br>return<br><br><br>> > some data back to the first script, but am having<br><br>difficulty. I use<br><br><br>> > the 'return' command to have the second script return control back<br><br>the<br><br><br>> > first script, but cannot seem to get any variable data to pass with<br><br><br>> > it. It seems this is possible per the Grads documentation:<br><br><br>> ><br><br><br>> > <br><br><br>> ><br><br><br>> > <br><br><br>> ><br><br><br>> > To return from a function, use the |return| command:<br><br><br>> ><br><br><br>> > |return /expression/|<br><br><br>> ><br><br><br>> > The |/expression/| is optional; if not<br><br>provided, a NULL string<br><br><br>> > will be returned. (A null string is: '') The<br><br>result of the<br><br><br>> > function is the result of the expression<br><br>specified on the return<br><br><br>> > command.<br><br><br>> ><br><br><br>> > <br><br><br>> ><br><br><br>> > In the second script, the last line is:<br><br><br>> ><br><br><br>> > <br><br><br>> ><br><br><br>> > return val1<br><br><br>> ><br><br><br>> > <br><br><br>> ><br><br><br>> > Where val1 is a variable string<br><br><br>> ><br><br><br>> > <br><br><br>> ><br><br><br>> > Just can't seem to get the first script to read the contents of<br><br><br>> > val1. Could always write the data to a file, but am looking for<br><br><br>> > something a little more elegant.<br><br><br>> ><br><br><br>> ><br><br><br>> > <br><br><br>> ><br><br><br>> > Any help would be appreciated,<br><br><br>> > Mark<br><br><br>> ><br><br><br>> ><br><br>------------------------------------------------------------------------<br><br><br>> ><br><br><br>> > _______________________________________________<br><br><br>> > gradsusr mailing list<br><br><br>> > <A href="mailto:gradsusr@gradsusr.org" target=_blank>gradsusr@gradsusr.org</A><br><br><br>> > <A href="http://gradsusr.org/mailman/listinfo/gradsusr" target=_blank>http://gradsusr.org/mailman/listinfo/gradsusr</A><br><br><br>> > <br><br><br>><br><br><br>> -- <br><br><br>><br><br><br>> Please note that <A href="mailto:Charles.Seman@noaa.gov" target=_blank>Charles.Seman@noaa.gov</A> should be considered my NOAA<br><br><br>> email address, not <A href="mailto:cjs@gfdl.noaa.gov" target=_blank>cjs@gfdl.noaa.gov</A>.<br><br><br>><br><br><br>> ********************************************************************<br><br><br>> Charles<br><br>Seman <A href="mailto:Charles.Seman@noaa.gov" target=_blank>Charles.Seman@noaa.gov</A><br><br><br>> U.S. Department of Commerce / NOAA / OAR<br><br><br>> Geophysical Fluid Dynamics<br><br>Laboratory voice: (609)<br><br>452-6547<br><br><br>> 201 Forrestal<br><br>Road fax:<br><br>(609) 987-5063<br><br><br>> Princeton,<br><br>NJ 08540-6649 <A href="http://www.gfdl.noaa.gov/~cjs/" target=_blank>http://www.gfdl.noaa.gov/~cjs/</A><br><br><br>> ********************************************************************<br><br><br>><br><br><br>> "The contents of this message are mine personally and do not reflect<br><br>any<br><br><br>> official or unofficial position of the United States Federal Government,<br><br><br>> the United States Department of Commerce, or NOAA."<br><br><br>><br><br><br>> _______________________________________________<br><br><br>> gradsusr mailing list<br><br><br>> <A href="mailto:gradsusr@gradsusr.org" target=_blank>gradsusr@gradsusr.org</A><br><br><br>> <A href="http://gradsusr.org/mailman/listinfo/gradsusr" target=_blank>http://gradsusr.org/mailman/listinfo/gradsusr</A><br><br><br>> ------------------------------------------------------------------------<br><br><br>><br><br><br>> _______________________________________________<br><br><br>> gradsusr mailing list<br><br><br>> <A href="mailto:gradsusr@gradsusr.org" target=_blank>gradsusr@gradsusr.org</A><br><br><br>> <A href="http://gradsusr.org/mailman/listinfo/gradsusr" target=_blank>http://gradsusr.org/mailman/listinfo/gradsusr</A><br><br><br>> <br><br><br><br>-- <br><br><br><br>Please note that <A href="mailto:Charles.Seman@noaa.gov" target=_blank>Charles.Seman@noaa.gov</A> should<br><br>be considered my NOAA<br><br><br>email address, not <A href="mailto:cjs@gfdl.noaa.gov" target=_blank>cjs@gfdl.noaa.gov</A>.<br><br><br><br>********************************************************************<br><br><br>Charles<br><br>Seman <A href="mailto:Charles.Seman@noaa.gov" target=_blank>Charles.Seman@noaa.gov</A><br><br><br>U.S. Department of Commerce / NOAA / OAR<br><br><br>Geophysical Fluid Dynamics<br><br>Laboratory voice: (609)<br><br>452-6547<br><br><br>201 Forrestal<br><br>Road fax:<br><br>(609) 987-5063<br><br><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>********************************************************************<br><br><br><br>"The contents of this message are mine personally and do not reflect any<br><br><br>official or unofficial position of the United States Federal Government,<br><br><br>the United States Department of Commerce, or NOAA."<br><br><br><br>_______________________________________________<br><br><br>gradsusr mailing list<br><A href="mailto:gradsusr@gradsusr.org" target=_blank>gradsusr@gradsusr.org</A><br><br><br>http://gradsusr.org/mailman/listinfo/gradsusr</span></P></DIV></blockquote></DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"></span> </P></DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"><br><br><br>_______________________________________________ gradsusr mailing list<br><br>gradsusr@gradsusr.org http://gradsusr.org/mailman/listinfo/gradsusr </span></P></DIV></DIV></DIV>
<P class=MsoNormal><span style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 'Arial','sans-serif'"><br><br><br>_______________________________________________ gradsusr mailing list<br><br>gradsusr@gradsusr.org http://gradsusr.org/mailman/listinfo/gradsusr </span></P></DIV></DIV><br><br></body></html>