combine CATCH and MESSAGE [message #77901] |
Tue, 27 September 2011 08:26 |
natha
Messages: 482 Registered: October 2007
|
Senior Member |
|
|
Hello guys,
I used to use the CATCH method to catch the errors on my code but I
also like the method using ON_ERROR,2 and MESSAGE.
Right now, I would like to combine these 2 methods. Something like:
PRO TEST, arg_1, ERROR=error
CATCH, error_status
IF error_status EQ 0 THEN BEGIN
error=0
IF N_ELEMENTS(arg_1) EQ 0 THEN MESSAGE, 'Incorrect number of
arguments'
ENDIF ELSE BEGIN
error=1
CATCH, /CANCEL
ENDELSE
END
Note that in this routine, the output keyword error is very important.
The problem here is that I want the message to cause the error and
that is not happening. Do you know if there is a way to do that ? I
mean without doing :
IF N_ELEMENTS(arg_1) EQ 0 THEN BEGIN
MESSAGE, Incorrect number of arguments', /INFORMATIONAL
error=1
RETURN
ENDIF
I also would like to ask for your opinion. I like the output keyword
error, is very useful on my programs but I also like the MESSAGEs,
they make the program very clear.
Thanks for your help,
nata
|
|
|