Passing Keyword Parameters [message #15581] |
Mon, 31 May 1999 00:00 |
konu
Messages: 2 Registered: May 1999
|
Junior Member |
|
|
I want to write a procedure with the following prototype:
PRO easy_hist, file, hist_min = hist_min_val, hist_max = hist_max_val
Because I want hist_min_val and hist_max_val to be optional keyword
parameters, I use the following in easy_hist:
if (keyword_set(hist_min_val) eq 0) then hist_min_val = 1
if (keyword_set(hist_max_val) eq 0) then hist_max_val = 255
The procedure has a bug in the sense that, if it is called with
hist_min_val = 0, keyword_set(hist_min_val) returns zero and so
hist_min_val is set to its default value of 1. Clearly the user
intended to set hist_min_val equal to 0.
Is there a simple way fix this bug in my procedure?
Thanks,
Kristjan Onu
PS. I am using IDL Version 5.0.3 (sunos sparc).
|
|
|