[gradsusr] Custom (And Simple) Function Script Refuses To Pass Variable Back To Main Script

Jeff Duda jeffduda319 at gmail.com
Fri May 30 21:34:13 EDT 2014


I'm not 100% sure how returning a variable works when the function code is
contained within a different script file, but when you call it, the syntax
should be something like

fday2 = 'run /home/aaron/grads/day_abv.gsf 'fday

if that doesn't work, put the function code within the script you're
actually running.

Also, you can try making newday a global script variable by renaming it
with a leading underscore.  Then you may be able to access it from your
other script code just by virtue of having run the day_abv function in your
script.

Jeff Duda


On Fri, May 30, 2014 at 5:12 PM, Perry, Aaron @ LSC <Aaron.Perry at lsc.vsc.edu
> wrote:

>  Good Evening All,
>
> I'm currently trying to create a very simple function script (.gsf) where
> a weekday is changed from say "Sun" to "Sunday" and then plotted. I have
> sought help from a few people who are GrADS-proficient and they are as
> stumped as I am.
>
> Here's what I'm dealing with:
>
> *Function Script:*
>
> function convertday(fday)
>
> rc = gsfallow("on")
>
> if (fday="Sun"); newday="Sunday"; endif
> if (fday="Mon"); newday="Monday"; endif
> if (fday="Tue"); newday="Tuesday"; endif
> if (fday="Wed"); newday="Wednesday"; endif
> if (fday="Thu"); newday="Thursday"; endif
> if (fday="Fri"); newday="Friday"; endif
> if (fday="Sat"); newday="Saturday"; endif
>
> return(newday)
>
> *Command to function in main script:*
>
> '/home/aaron/grads/day_abv.gsf 'fday''
>
> *How I'm attempting to plot the variable:*
>
> 'draw string 2.60 8.05 Valid: 'thour' 'tz' ('thour2') 'newday' 'fday2'
> 'fmonth' 'fyear''
>
> Also, I'm using *'q time' fday = subwrd(result,6)* to get the actual
> weekday name at the top of the main script.
>
> This function should be working, as it's probably as simple as you could
> get for a function.
>
> Any ideas?
>
>
>     Onward and Upward,
>
> Aaron D. Perry
> Atmospheric Sciences
> Lyndon State College
> Class of 2016
> Boston, MA
> Twitter: @AaronPerryLSC <https://twitter.com/AaronPerryLSC>
> Mobile: 617-780-4312
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>


-- 
Jeff Duda
Graduate research assistant
University of Oklahoma School of Meteorology
Center for Analysis and Prediction of Storms
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20140530/34bad3a0/attachment.html 


More information about the gradsusr mailing list