Handler behaving oddly
Mark Schonewille
m.schonewille at economy-x-talk.com
Wed Jul 19 04:58:21 EDT 2006
Hi Ian,
You posted only a small part of your script. Without the handler that
calls the checkSize function, I can't be sure that my advice makes
sense.
If you have a script line
put checkSize(myAns) into fld "Display"
then the field will be empty because the function does not return
anything if myAns rep theAns is out of range. Instead of returning a
value, your exits to top and thus returns empty (I'm not even sure
that it really returns a "value" at all, in this case).
Try changing the function into:
function checksize theAns
-- check if too big or too small
if (theAns > 10^8 -1) or (theAns < 10^(-8))
then
return "Error"
else
set the numberformat to "0.########" -- maximum 8 places of decimals
return (char 1 to 10 of theAns ) -- show 10 sig figs truncated
end if
end checksize
Best regards,
Mark
--
Economy-x-Talk
Consultancy and Software Engineering
http://economy-x-talk.com
http://www.salery.biz
Download ErrorLib at http://economy-x-talk.com/developers.html and
get full control of error handling in Revolution.
Op 19-jul-2006, om 10:36 heeft Ian McKnight het volgende geschreven:
> Hi
>
> The handler below is designed to check that a value is within a
> certain range.
> If it is outside the range it displays the word ERROR and stops
> otherwise it displays the first 10 characters in the value.
>
> The handler behaves oddly.
> Values passed to it that are within the range are handled correctly.
>
> However, when a value is passed to it that is outside the range the
> fld "Display" shows up empty. Yet when I put the line
>
> put "Error" into message
>
> immediately before the existing Put "error" the word ERROR appears
> in the message box and when I type
>
> put "Error" into fld "Display"
>
> into the message box, I get the expected output ie "Error" appears
> in the field.
>
> I have stepped through the handler in the Debugger and the statements
> execute in the correct order. I even checked that the text colour had
> not been changed to white!
>
> Any advice would be much appreciated
>
>
> Thanks
>
> Ian McKnight
>
> ===============================================
>
> function checksize theAns
> -- check if too big or too small
> if (theAns > 10^8 -1) or (theAns < 10^(-8))
> then
> put "Error" into fld "Display"
> exit to top
> else
> set the numberformat to "0.########" -- maximum 8 places of
> decimals
> return (char 1 to 10 of theAns ) -- show 10 sig figs truncated
> end if
> end checksize
>
More information about the use-livecode
mailing list