Re: Need an example of how to use try and catch

2012-03-23 Thread Jim Hurley
Mark, Yes! I agree with you about throw. Do you, or dose anyone, have an example that shows the use of the throw command in conjunction with the try-catch structure? Jim Message: 4 Date: Thu, 22 Mar 2012 22:33:42 -0700 From: Mark Wieder mwie...@ahsoftware.net To:

Re: Need an example of how to use try and catch

2012-03-23 Thread Pete
Bob, Maybe I'm missing something but you seem to be saying there are some database errors that can only be detected by using try/catch, not by checking the result or the revdberr string. Taking your example of a database going away, I just created a small db, opened it in LC, then deleted the db

Re: Need an example of how to use try and catch

2012-03-23 Thread Peter M. Brigham, MD
The syntax is there at the top but it's not formatted -- tabs or space-runs between the lines instead of cr's. Looks like a problem in the dictionary stack with displaying the text from the customprop. If it were displayed properly you could see the structure, and then the commentary would

Re: Need an example of how to use try and catch

2012-03-22 Thread Bob Sneidar
try put foo into myVar put the value of myVarr catch theError, theNum -- breakpoint answer theNum cr line1 of theError as sheet exit to top end try Is that what you mean? Bob On Mar 22, 2012, at 8:33 AM, Jim Hurley wrote: The dictionary needs an example of how the try command is

Re: Need an example of how to use try and catch

2012-03-22 Thread Peter M. Brigham, MD
On Mar 22, 2012, at 11:33 AM, Jim Hurley wrote: The dictionary needs an example of how the try command is used to catch an error. Anyone have an illustration? For example, suppose one wanted to catch an error in the statement: put the {some built-in property of an object] of button

Re: Need an example of how to use try and catch

2012-03-22 Thread Jim Hurley
Bob, Yes that would be fine, except that I get a compilation error at the line: catch theError, theNum RR says: (try: not a command), char 7 Jim Bob Sneidar wrote: try put foo into myVar put the value of myVarr catch theError, theNum -- breakpoint answer theNum cr line1

Re: Need an example of how to use try and catch

2012-03-22 Thread Peter M. Brigham, MD
On Mar 22, 2012, at 11:33 AM, Jim Hurley wrote: For example, suppose one wanted to catch an error in the statement: put the {some built-in property of an object] of button soAndso into tProp Where the built in property may not exist.How would one catch the error and perhaps proceed on

Re: Need an example of how to use try and catch

2012-03-22 Thread Peter M. Brigham, MD
On Mar 22, 2012, at 12:22 PM, Jim Hurley wrote: Bob, Yes that would be fine, except that I get a compilation error at the line: catch theError, theNum RR says: (try: not a command), char 7 The syntax for the try construction is try command here catch tError other commands

Re: Need an example of how to use try and catch

2012-03-22 Thread Pete
You're getting an error because the catch part of try takes only 1 parameter - the variable that holds the error - not two as in the script. Also, as noted by Peter, the try statement doesn't help you with the specific example you used since getting a non-existant custom property doesn't cause an

Re: Need an example of how to use try and catch

2012-03-22 Thread Bob Sneidar
Whoops maybe the second argument is not valid. On Mar 22, 2012, at 9:22 AM, Jim Hurley wrote: Bob, Yes that would be fine, except that I get a compilation error at the line: catch theError, theNum RR says: (try: not a command), char 7 Jim Bob Sneidar wrote: try put foo

Re: Need an example of how to use try and catch

2012-03-22 Thread Bob Sneidar
Also I forgot the finally part try -- some statements catch theError -- do some stuff if there is an error finally -- do some other stuff no matter what end try On Mar 22, 2012, at 9:22 AM, Jim Hurley wrote: Bob, Yes that would be fine, except that I get a compilation error at

Re: Need an example of how to use try and catch

2012-03-22 Thread Jim Hurley
It does give an error here. I get the error message: button Button: execution error at line n/a (Object: object does not have this property) Jim Message: 2 Date: Thu, 22 Mar 2012 09:55:20 -0700 From: Pete p...@mollysrevenge.com To: How to use LiveCode use-livecode@lists.runrev.com

Re: Need an example of how to use try and catch

2012-03-22 Thread Jim Hurley
Thanks Peter. The problem now is what do these bloody error numbers translate into. Is the a list somewhere? When I try: on mouseUP try put the cantdelete of me into temp catch tErr --- if tErr is ?? end try end mouseUP I get an error of 348,0,0 Jim Peter Brigham wrote: The

Re: Need an example of how to use try and catch

2012-03-22 Thread J. Landman Gay
On 3/22/12 12:21 PM, Jim Hurley wrote: Thanks Peter. The problem now is what do these bloody error numbers translate into. Is the a list somewhere? The list is explained in the errordialog entry in the dictionary. You can retrieve the list with the line of script the dictionary provides.

Re: Need an example of how to use try and catch

2012-03-22 Thread Peter M. Brigham, MD
On Mar 22, 2012, at 1:11 PM, Jim Hurley wrote: It does give an error here. I get the error message: button Button: execution error at line n/a (Object: object does not have this property) Sounds as if you're trying to get a built-in property that doesn't apply to that type of object. If

Re: Need an example of how to use try and catch

2012-03-22 Thread Michael Doub
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. -= Mike On Mar 22, 2012, at 1:21 PM, Jim Hurley wrote: Thanks Peter. The problem now is what do these bloody error numbers translate into. Is the a

Re: Need an example of how to use try and catch

2012-03-22 Thread Peter M. Brigham, MD
On Mar 22, 2012, at 1:21 PM, Jim Hurley wrote: Thanks Peter. The problem now is what do these bloody error numbers translate into. Is the a list somewhere? Jacque posted this two days ago: On 3/20/12 12:37 PM, Ralph DiMola wrote: OK, I give up. How do you translate error number

RE: Need an example of how to use try and catch

2012-03-22 Thread Ralph DiMola
I second this! Ralph DiMola IT Director Evergreen Information Services rdim...@evergreeninfo.net Also, as noted by Peter, the try statement doesn't help you with the specific example you used since getting a non-existant custom property doesn't cause an error. I've sometimes wished there was a

Re: Need an example of how to use try and catch

2012-03-22 Thread Peter M. Brigham, MD
On Mar 22, 2012, at 1:32 PM, J. Landman Gay wrote: On 3/22/12 12:21 PM, Jim Hurley wrote: Thanks Peter. The problem now is what do these bloody error numbers translate into. Is the a list somewhere? The list is explained in the errordialog entry in the dictionary. You can retrieve the

Re: Need an example of how to use try and catch

2012-03-22 Thread Bob Sneidar
I use it to determine if there has been an error executing a sequel query for example. All my database calls go inside a try catch statement. If you put it into a repeat loop, you can test to see if perhaps you have been disconnected, or if a runtime error occurred due to a bad query, and then

Re: Need an example of how to use try and catch

2012-03-22 Thread Pete
Interesting, never thought of that. Is there an advantage to doing that over just issuing the database call and checking for an error right after? I've mostly thought of try/catch for as a debugging tool. I also use it any place where I put together a command in a variable and execute the

Re: Need an example of how to use try and catch

2012-03-22 Thread Mark Wieder
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

Re: Need an example of how to use try and catch

2012-03-22 Thread Bob Sneidar
No advantage per se, but I use sqlYoga and the only way to determine what went wrong is in a try catch statement as the libSQLYoga stack is locked. Bob On Mar 22, 2012, at 11:49 AM, Pete wrote: Interesting, never thought of that. Is there an advantage to doing that over just issuing the

Re: Need an example of how to use try and catch

2012-03-22 Thread Bob Sneidar
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

Re: Need an example of how to use try and catch

2012-03-22 Thread Bernard Devlin
I have been using the try/catch idiom for years. I like the structure it gives my code - visually it makes it very clear where I am expecting problematic sections to be. I rarely use 'finally'. However the problem has always been with interpreting the error codes that arise. For years I got

Re: Need an example of how to use try and catch

2012-03-22 Thread Jim Hurley
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

Re: Need an example of how to use try and catch

2012-03-22 Thread Bob Sneidar
When you are in a standalone, a runtime error that would halt execution might be fatal. Try/Catch allows you to handle the error gracefully without presenting the user with an ugly dialog and a QTD afterwards. You can politely inform the user that something has gone wrong and you have to exit

Re: Need an example of how to use try and catch

2012-03-22 Thread Tim Jones
Or - this can be applied to a night out clubbing - try put myBestPickupLine into myMouth catch theResponse If theResponse is not negative -- Oh yeah! set luckynight to true else put wittingComback into myMouth move body to new location finally if not

Re: Need an example of how to use try and catch

2012-03-22 Thread Jim Hurley
Jacque, Thanks. LC is an English muffin. So many nooks and crannies. Jim P.S. There really ought to be an illustration of the try-catch syntax in the dictionary. Message: 5 Date: Thu, 22 Mar 2012 12:32:01 -0500 From: J. Landman Gay jac...@hyperactivesw.com To: How to use LiveCode

Re: Need an example of how to use try and catch

2012-03-22 Thread J. Landman Gay
On 3/22/12 11:59 PM, Jim Hurley wrote: LC is an English muffin. So many nooks and crannies. I like that. :) P.S. There really ought to be an illustration of the try-catch syntax in the dictionary. I just looked, and I'm amazed there isn't. Myabe you could add a user note. -- Jacqueline

Re: Need an example of how to use try and catch

2012-03-22 Thread Mark Wieder
Jacque- Thursday, March 22, 2012, 10:19:59 PM, you wrote: P.S. There really ought to be an illustration of the try-catch syntax in the dictionary. I just looked, and I'm amazed there isn't. Myabe you could add a user note. Yeah - the throw command should be mentioned there as well. --