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

Jim Hurley jhurley0305 at sbcglobal.net
Thu Mar 22 18:06:10 EDT 2012


The following script will provide a start in finding all the property values of a given object, in this case the button "button"

It starts with "the propertynames" which is a list of ALL built-in property names in LC. 

It then attempts to put the value of each of these properties for the given object.

If the attempt was successful, it goes into the object property list, otherwise not.


on mouseUp
   put the propertynames into tProps
   repeat for each line tLine in tProps
      put "" into tErr
      try
         put the  tLine of button "button" into tPropVal
      catch tErr
         put tLine & cr after tOmits
         next repeat
      end try
      if tPropVal is not empty then put tLine & tab & tPropVal & cr after tSaves
   end repeat
   put tSaves into field "saves"
   put tOmits into field "omits"
end mouseUp



More information about the use-livecode mailing list