In article <405594fa.0403100119.34769176@posting.google.com>, "Tim
Robishaw" <timrobishaw@yahoo.com> wrote:
> Hi there,
> I've been using _REF_EXTRA for a long time now and have come to
> appreciate that values of keywords sent to a module with the _REF_EXTRA
> mechanism will override any keywords that are set inside the module.
> Here is a great example: pro whaddup, _REF_EXTRA=_extra
> plot, [0], [0], /NODATA, XRANGE=[-5,5], YRANGE=[-5,5], PSYM=4,
> _EXTRA=_extra
> end
> IDL> whaddup
> I see what the module asked for: axes from -5 to 5 with no datum
> plotted.
> Now I can override the XRANGE and YRANGE keyword values by passing them
> by reference...
> IDL> whaddup, XRANGE=[-1,1], YRANGE=[-1,1] I see what I asked for: axes
> from -1 to 1. However, if I send NODATA set to ZERO, i.e., I'd really
> like to see my datum this time...
> IDL> whaddup, XRANGE=[-1,1], YRANGE=[-1,1], NODATA=0 I don't get what I
> asked for. The value for NODATA sent by reference does not override the
> value set inside the module. This is also true for the /NOERASE
> keyword.
> IDL newsgroup: whaddup?
Hi,
IDL> plot, findgen(10), nodata=1
IDL> plot, findgen(10), nodata=1,nodata=0
% Duplicate keyword NODATA in call to: PLOT
% Execution halted at: $MAIN$
IDL> e={nodata:0}
IDL> plot, findgen(10), nodata=1,_EXTRA=e
Duplicate keywords give IDL no chance of knowing what to do, hence it
complains, and it only looks in the _EXTRA struct if it doesn't find what
it wants elsewhere. If you want an option of overriding the nodata
keyword, you need to look for it first, hence
pro whaddup, nodata=nodata,_REF_EXTRA=_extra
nodata_internal = 0
if(arg_present(nodata)) then nodata_internal=nodata > 0 < 1
plot, [0], [0], NODATA=nodata_internal, XRANGE=[-5,5], YRANGE=[-5,5], PSYM=4,
_EXTRA=_extra
end
This works for any boolean keyword, for multi valued /array keywords you
need N_ELEMENTS and IF..THEN..ELSE, depending on the default conditions you want
for the variable.
Chris.
|