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

Home » Public Forums » archive » Re: how to catch a math error?
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: how to catch a math error? [message #34804] Thu, 17 April 2003 12:55
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
J Li (anonymous@nowhere.com) writes:

> I am trying to figure out how to trap the math error and dump the error
> message to a file. Math error is somehow different than other types of
> errors? My test program is listed below.
>
> I have done tests for I/O error or raising an exception by issuing a
> "message" call. They all work as expected, that is I got error message in
> the myLog.err file and the program exited gracefully. So far, I have not
> been able to do the same for math error. Please help!

I'd try something like this:

pro test3
on_error, 2
print, "I am in test3"
junk = check_math()
x = 1 / 0
CASE check_math() OF
0:
1: Message, 'Integer divide by zero in Test 3.'
2: Message, 'Integer overflow in Test 3.'
16: Message, 'Floating point divide by zero in Test 3.'
32: Message, 'Floating point underflow in Test 3.'
64: Message, 'Floating point overflow in Test 3.'
128: Message, 'Floating point operand error in Test 3.'
ENDCASE
end

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Previous Topic: how to catch a math error?
Next Topic: "menu item skipped a level"

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

Current Time: Fri Oct 10 14:34:34 PDT 2025

Total time taken to generate the page: 0.72260 seconds