[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

keyword question



Greetings all,

I am trying to have an array *optionally* returned using a keyword
and I don't know the dimension of the array prior to the call.  Why is
it that the passed keyword needs to be defined in IDL prior to being used
as a keyword?  

What am I doing wrong here?

Cheers,
Randall

Here is an example:
---
function test, a, b=b
 a = 1.0
 if (keyword_set(b)) then b = fltarr(10)
 return, 1
end
--

***This works as I'd expect:
IDL> print, test(a) && help, a 
       1
A               FLOAT     =       1.00000

***This does not work as I expect:
IDL> print, test(a,b=duh) && help, a, duh
       1
A               FLOAT     =       1.00000
DUH             UNDEFINED = <Undefined>

***This works which makes me mad:
IDL> duh = 1
IDL> print, test(a,b=duh) && help, a, duh
       1
A               FLOAT     =       1.00000
DUH             FLOAT     =       Array(20)