Re: optional argument for function / procedure

From: Oliver Fuhrer (MeteoSwiss) <oliver.fuhrer_at_nyahnyahspammersnyahnyah>
Date: Mon Mar 04 2013 - 05:39:46 MST

Hi Tim,

You can achieve this easily using resources...

undef("mytest")
procedure mytest( var, res )
local var, res
begin

if (res) then
   r = res
else
   r = True
end if

if (isatt(r,"option1")) then
   ;; use r@option1 here
end if

;; rest of code

end

You can then call this procedure similar to the gsn_XXX functions, for
example...

mytest(var, False)

r = True
r@option1 = "this is option 1"
mytest(var, r)

...and add as many options as you like.

Cheers,
Oli

On 04.03.2013 13:34, Brücher Tim wrote:
> Dear all,
>
> is there a way to pass one (or several) optional argument(s) to a
> function or procedure like in e.g. f90?
>
> If I look at "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
> there are functions waiting for an option, but the opts-argument has
> to be given all the time the function / subroutine is called, so it
> is
> not really optional.
>
>
> Thanks for your help,
>
> Tim
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
_________
Oliver Fuhrer
Numerical Models
Federal Departement of Home Affairs FDHA
Federal Office of Meteorology and Climatology MeteoSwiss
Kraehbuehlstrasse 58, P.O. Box 514, CH-8044 Zurich, Switzerland
Tel. +41 44 256 93 59
Fax +41 44 256 92 78
oliver.fuhrer@ginko.ch
www.meteoswiss.ch - First-hand information
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Mar 4 05:39:55 2013

This archive was generated by hypermail 2.1.8 : Thu Mar 07 2013 - 08:55:58 MST