Re: output keywords [message #4071] |
Wed, 26 April 1995 00:00 |
sjt
Messages: 72 Registered: November 1993
|
Member |
|
|
Darren Orbach (orbach@rockvax.rockefeller.edu) wrote:
: Here's a question
about output variables and keywords: it seems that I cannot : create a
new variable using an output keyword, but can modify an already : existing
one. The specific program I wrote is an image viewer, which opens a
specified : file and displays an image, and can be called with an
additional keyword for output : (e.g. iname = iname). If iname has never
been defined before, then after calling my : viewer, if I type: info,
iname, I get: INAME UNDEFINED=<Undefined>. However, if : I first define
iname, say as a 100*100 fltarr, after running my viewer, iname is rescaled
: to fit whatever size the image was that I was viewing (in this example,
info, iname) yields: : INAME FLOAT = Array(384, 288). Why is this?
: Darren Orbach
Maybe you have a check on keyword_set in your procedure. If so, then
passing an undefined keyword will not return false from the keyword_set
function (defined to return 0 if the argument is undefined or scalar
zero, 1 otherwise).
e.g.
pro sks, kv=kv
if (keyword_set(kv)) then kv=findgen(200)
end
won't do anything if called with an undefined kv key. But:
pro sks, kv=kv
kv = findgen(200)
end
will work, and it won't fall over if you don't give a key, kv will just
be a local variable.
--
+------------------------+---------------------------------- --+---------+
| James Tappin, | School of Physics & Space Research | O__ |
| sjt@star.sr.bham.ac.uk | University of Birmingham | -- \/` |
| Ph: 0121-414-6462. Fax: 0121-414-3722 | |
+----------------------------------------------------------- --+---------+
|
|
|