Using 'try'
Mark Wieder
mwieder at ahsoftware.net
Thu Apr 13 16:36:23 EDT 2006
Graham-
Thursday, April 13, 2006, 12:28:52 AM, you wrote:
> In the very interesting discussion on Custom Properties, Mark Wieder
> introduced this example
>> setProp NewValue pValue
>> try
>> if pValue < 0 then
>> set the foreColor of me to "red"
>> else
>> set the foreColor of me to empty
>> end if
>> end try
>> put pValue into me
>> end NewValue
> I think I get the idea, but Mark, why did you use 'try'? It would not
David Burgun as provided the longer-winded explanation (and a great
one at that - not meant as putting it down), but basically the "try"
construct here lets me set the field to empty without running into a
runtime error. Without the try the code would give me an error on the
first line if pValue is empty, since it would try to execute
if < 0 then
Putting the code inside a try construct lets me ignore the error that
results from trying to execute an illegal statement and move on to the
next line of executable code after the end try.
--
-Mark Wieder
mwieder at ahsoftware.net
More information about the use-livecode
mailing list