comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Pass-By-Reference question.
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Pass-By-Reference question. [message #38509 is a reply to message #38498] Wed, 10 March 2004 01:37 Go to previous messageGo to previous message
Chris Lee is currently offline  Chris Lee
Messages: 101
Registered: August 2003
Senior Member
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.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL online help for v6.0 (sigh)
Next Topic: Re: Pass-By-Reference question. (ARG_PRESENT)

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 13:05:14 PDT 2025

Total time taken to generate the page: 1.92120 seconds