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

Home » Public Forums » archive » Passing optional parameters through a wrapper routine
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: Passing optional parameters through a wrapper routine [message #18915 is a reply to message #18840] Thu, 10 February 2000 00:00 Go to previous messageGo to previous message
edward.s.meinel is currently offline  edward.s.meinel
Messages: 12
Registered: May 1999
Junior Member
In article <950129121.690143@clam-55>,
"Mark Hadfield" <m.hadfield@niwa.cri.nz> wrote:

> That's an interesting point David. The first few lines
> of my routines tend to look something like this:
>
> if n_elements(arg1) then message, 'You haven't defined arg1'

...

> 2. The principle that in scientific programming
> (as opposed, say, to Web page programming)
> it is much better for programs to crash than to continue
> and return bad data.

Ugh, I *hate* MESSAGE. Why cause a crash when it is easy to exit nicely?
How about:

IF N_ELEMENTS(arg1) EQ 0 THEN BEGIN
print, 'You haven't defined arg1'
RETURN
ENDIF

or even:

IF N_ELEMENTS(arg1) EQ 0 THEN BEGIN
dummy = DIALOG_MESSAGE('You haven't defined arg1')
RETURN
ENDIF

This way the user gets the message, but the program doesn't crash. This
is especially helpful when the procedure is used in a widget -- I don't
have to manually clean up everything before trying again.

> if size(arg2, /TNAME) ne 'STRING' then message, 'Arg2 must be string
> specifying the file name'

...

> if in doubt, stop and call for help.

Right, but you can stop and ask for help without forcing a crash. How
about:

IF SIZE(arg2, /TNAME) NE 'STRING' THEN BEGIN

; Oooops! forgot the file name.

arg2 = DIALOG_PICKFILE(set_the_appropriate_keywords)
IF arg2 EQ '' THEN BEGIN
dummy = DIALOG_MESSAGE( $
'You must provide a file name as the second argument')
RETURN
ENDIF
ENDIF

Ed Meinel


Sent via Deja.com http://www.deja.com/
Before you buy.
[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
Previous Topic: Superscripts in IDL [x-y]title
Next Topic: superscripts

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

Current Time: Fri Oct 10 16:59:27 PDT 2025

Total time taken to generate the page: 1.03590 seconds