throw vs the result
J. Landman Gay
jacque at hyperactivesw.com
Sun May 1 00:38:38 EDT 2005
On 4/30/05 11:27 PM, Phil Davis wrote:
> Dar Scott wrote:
>
>> OK, well, what about a library that exports lots of functions, such as
>> a math library? Functions don't have a separate result for an error.
>>
>> Should the error be a special value in the result and propagated through?
>> Or should an error function tell whether there was an error since the
>> last call to error function?
>> Or should an error be thrown?
>
>
>
> I like the 'special value' idea.
>
> What if the last (or first?) param passed to the function by my script
> is the value to be returned to my script if an error occurs?
The HyperCard standard for this was to preceed the value with a special
string, commonly "Error:". Then your handler just checks to see if word
1 is that string.
put myFunction() into tValue
if word 1 of tValue = "Error:" then
-- something went wrong; check the rest of the string
else
-- do your thing
end if
Not fancy, but it works.
--
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the use-livecode
mailing list