Passing arguments to Grads script

Ben-Jei Tsuang btsuang at YAHOO.COM
Mon Jan 31 22:55:54 EST 2005


Dear Dan:

You can put the following script in the top of the script
------------------------------------
function main(args)
'reinit'
say "temps.gs " args
* Get arguments
if (args='?')
  say 'temps.gs requires 1 argument: hh'
  say 'hh = local time'
  return
else
  hh=subwrd(args,1);if(hh='');hh="";endif
endif


'draw title Current Temperatures as of 'hh

--------------------------------------------
Ben

Ben-Jei Tsuang, Prof
Nat'l Chung-Hsing Univ.
Dept. of Environmental Engineering
email: tsuang at nchu.edu.tw



----- Original Message -----
From: "Daniel Leins" <daniel.leins at NOAA.GOV>
To: <GRADSUSR at LIST.CINECA.IT>
Sent: Tuesday, February 01, 2005 9:37 AM
Subject: Passing arguments to Grads script


> All,
> I have written a script to plot temperatures across a given area.  When it
> comes to titling the images, I would like to pass the current time to the
> script, then have this argument displayed through 'draw title'.  For
> example,
>
> If it is 15:00, I would like to pass the time to my script, and do
> something
> like
>
> draw title Current Temperatures as of @ARGV[0]
>
> where @ARGV[0] comes from gradsdods -l -b -c "run temps.gs 15:00"
>
> (i am aware that @ARGV[0] is not correct, I am simply using this syntax as
> an example).
>
> OR
>
> If I wanted to pass the title itself to the script instead of the time,
> for
> example:
>
> draw title @ARGV[0]
>
> where @ARGV[0] comes from gradsdods -l -b -c "run temps.gs Dewpoints"
>
> I've looked through several scripts online which involve passed arguments,
> however I haven't been able to find anything that pertains to this.  I
> don't
> need to perform any sort of calculations on the passed argument, I simply
> need to pass it into the script, and have it passed back out in the title
> section.  What is the best way to accomplish this?
>
> Thanks,
>
> Dan Leins
> DOC/NOAA/NWS/EAX



More information about the gradsusr mailing list