Author: L ALVEY
Posted: 2013-08-12 at 04:18:25
It seems that division by zero is not caught by VFP. In the command window, type ? 1/0 <return>, and you get a line of asterisks, right? (I'm running VFP9 SP2.)
I have a form which evaluates a string expression and sends the result back to its caller. The only way I have found to catch division by zero is in a form method like this:
LOCAL loEx As Exception, lnTmp As Double
*!* THIS.cExpr is entered into an edit box on the form, THIS.nRetVal is the form return value
loEx = .NULL.
TRY
THIS.nRetVal = EVALUATE(THIS.cExpr)
lnTmp = 1/THIS.nRetVal
= MOD(THIS.nRetVal, lnTmp) && catches error 1307
CATCH TO loEx
ENDTRY
IF ISNULL(loEx)
THIS.Release()
ELSE
THIS.HandleException(loEx)
ENDIF
I think it wrong that VFP does not catch this error natively, unless I've missed a SET command or SYS() function.
Any thoughts people?
Laurie Alvey
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/1376299105.95892.YahooMailNeo@web87903.mail.ir2.yahoo.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.