[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is n_params() supposed to behave this way?
- Subject: Re: Is n_params() supposed to behave this way?
- From: mallors(at)ips1.msfc.nasa.gov (Robert S. Mallozzi)
- Date: 23 Aug 1999 20:25:43 GMT
- Newsgroups: comp.lang.idl-pvwave
- Organization: http://www.msfc.nasa.gov/
- References: <7ps7r7$i9p$1@nnrp1.deja.com>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:16258
In article <7ps7r7$i9p$1@nnrp1.deja.com>,
Mirko Vukovic <mvukovic@taz.telusa.com> writes:
> Consider the following code:
>
> pro sub1,arg1,arg2,arg3,arg4,arg5
>
> message,/info,string(n_params())
>
> return
>
> end
>
> pro sub,arg1,arg2,arg3,arg4,arg5
>
> message,/info,string(n_params())
>
> sub1,arg1,arg2,arg3,arg4,arg5
>
> return
> end
>
> If at the command prompt I do
>
> sub,4
>
> IDL will print out
> IDL> sub,4
> % SUB: 1
> % SUB1: 5
>
> In sub1 all arguments except the first one are still undefined.
Interesting, I ran across this same behavior today. I
fixed my code by switching to N_ELEMENTS instead of
N_PARAMS. The code is a little messier, but it works :-)
The N_PARAMS documentation is not totally clear, but
I suppose it passes for being correct:
"This function always returns the number of parameters
that were used in calling the procedure or function
from which N_PARAMS is called."
Add the caveat "even if those parameters are undefined" !
-bob
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Robert S. Mallozzi 256-544-0887
Mail Code SD 50
Work: http://gammaray.msfc.nasa.gov/ Marshall Space Flight Center
Play: http://cspar.uah.edu/~mallozzir/ Huntsville, AL 35812
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~