[Thread Prev][Thread Next][Index]

oops: Variable number of arguments to GO tool without default values



Excuse me everyone,
In my message just now I had a typo -- the third example calling the script
should have a period after the C:

GO var_args A. B. C.    ! gives A.B.C.plt
 

Ansley Manke

---------------------------------------------------------------------------------

Hi Gary,
Here's something that will work.  It uses the fact that in a go script, $* is replaced
by all the arguments separated by spaces (section 5.3.4 of the on-line Ferret Users
Guide, and then applies the PPL command $edit  to edit the string that results,
removing the spaces. (The ppl commands are documented in:
http://ferret.wrc.noaa.gov/Ferret/Documentation/PPLUS_Users_Guide/pplus_users_guide.html)

In your script var_args.jnl:
   DEFINE SYMBOL all_args = $*
   PPL SET filename $EDIT(all_args, COLLAPSE)
   SET MODE META ($filename)plt    ! note no .   this will come in with the argument(s)

Then you'd call it with a period included as part of each argument

   GO var_args A.            ! gives A.plt
   GO var_args A. B.        ! gives A.B.plt
   GO var_args A. B. C    ! gives A.B.C.plt

 and so forth.

--Ansley Manke
 

Gary Strand wrote:

(I'm a regular font of questions today.)

I want to pass N (N <= 9) arguments to a GO script but I don't want or need
default values for them. For example:

Inside var_args:

[I know this doesn't work]

set mode meta $1.$2.$3.$4.plt

And when it's called:

GO var_args A [gives A.plt]

GO var_args A B [gives A.B.plt]

GO var_args A B C [gives A.B.C.plt]

and so on.

Do I need a really big if-else-then block to do this? Thanks.

--
Gary Strand                Climate Change Research Section, NCAR (303) 497-1336
strandwg@ucar.edu                         http://www.cgd.ucar.edu/ccr/strandwg

--
Ansley Manke  Pacific Marine Environmental Laboratory  Seattle WA  (206)526-6246
 
[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement