Re: handling errors through catch
- From: claird@xxxxxxxxx (Cameron Laird)
- Date: Fri, 28 Apr 2006 00:08:11 GMT
In article <1146175975.484314.83780@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
maura.monville@xxxxxxxxx <maura.monville@xxxxxxxxx> wrote:
So far I've bothered you all trying to eliminate the folloeing error.
% set mum 20000000000
20000000000
set num_pnt [expr $mum-int($mum)]
integer value too large to represent
Since the value returned, wtitten in a point-info window, is correct I
wonder whether it would be simpler just suppress such an arror message.
To this purpose I was thinking of replacing the following
error-causing statement:
set num_pnt [expr $num-int($num)]
with
catch {set num_pnt [expr $num-int($num)]}
Is it going to fail or work ?
.
.
It'll work.
That's a miserable answer, though. Here's what you really need to hear:
it's impressive that you managed to figure out [catch] as well as you
have from where you started. If suppression of an exception dialogue is
all you want, we'll be happy for you, and you can continue with your
other work.
If you're going to work with Tcl at all, though, you need to understand
very quickly that you have everything at hand to answer questions like
yours with much greater ease than asking here in comp.lang.tcl. It's
urgent that you learn to use the interactive tclsh interpreter (or
equivalent) in sessions like this one:
% set num 20000000000
20000000000
% set num_pnt [expr $num-int($num)]
integer value too large to represent
% catch {set num_pnt [expr $num-int($num)]}
1
That's less typing than you needed to explain your question, and tclsh
is far faster than a trip through Usenet.
All this is bogus, though--"num_pnt" still has no value after the
sequence under discussion, for the $num you've chosen. This makes me
think you're working with code which generates only errors, not
useful computations. Without definite acceptance criteria, ANYTHING
"works".
I have one other suggestion. Thank you for making the
if ...
append num .
insertion I mentioned earlier. Retain that. Now, change
set num_pnt [expr $num-int($num)]
to
set num_pnt [expr fmod($num, 1.)]
Does that help your symptoms?
.
- References:
- handling errors through catch
- From: maura.monville@xxxxxxxxx
- handling errors through catch
- Prev by Date: Re: How to debug Tcl procs
- Next by Date: Tcl_Ungets help [long, technical]?
- Previous by thread: handling errors through catch
- Next by thread: Re: handling errors through catch
- Index(es):