Passing arguments to Grads script

Daniel Leins Daniel.Leins at NOAA.GOV
Tue Feb 1 00:34:29 EST 2005


Ok, this works fine. Now, what if I get greedy and want to pass an "AM"
or "PM" timestamp to the title as well, i.e. I've passed a "3", now I
want to pass "PM"
so the title reads "Current Temperatures as of 3 PM. Or, what if I want
to pass the month/day/year and add that into the title as well. I've
been successful in getting this data into the script and getting it to
display in the title, however, how do I add spaces between these
arguments? Right now, it's coming out like this:

Current Temps as of 10:00PM020105

What if I wanted a space between the PM and the 02? What's the best way
to accomplish this?

Thanks,
Dan

Ben-Jei Tsuang wrote:

> 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