Need an example of how to use "try" and "catch"

Bob Sneidar bobs at twft.com
Thu Mar 22 16:29:17 EDT 2012


RunRev was thinking of calling the try construct, "TryAndDontStopDeadInYourTracksUponAnError" but they opted for the shorter version. ;-)

Bob


On Mar 22, 2012, at 1:08 PM, Mark Wieder wrote:

>> On Mar 22, 2012, at 10:33 AM, Michael Doub wrote:
>> 
>>> Does anyone have any guidelines as to when you should use the try and catch
> structure?   I don't really know
>> when or when not to use it.
> 
> Here's another use (and apropos a different thread here)
> 
> In order to recreate a control you'd want to
> 
> 1. get the list of properties and their values
> 2. create a new control of the same type
> 3. set each of the properties to the original value
> 
> One problem with this is that some properties are read-only, and some can only
> be applied to the parent object (can't set the rect of a card, for example).
> 
> So I do something like
> 
> repeat for each element tProp in tPropertyArray
>  try
>    set the tProp of tNewControl to tPropertyArray[tProp]
>  catch e
>    -- just ignore the error here
>  end try
> end repeat
> 
> -- 
> Mark Wieder
> 
> 
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list