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 expla

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

2012-03-23 Thread Bob Sneidar
Hi Pete. I am not saying that try/catch is necessary when using revDB, but it certainly is when using sqlYoga, or any other plugin that is a locked stack that can generate errors. I would use try catch anyway because I am used to it, and if I am using it in certain places, then for consistency

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

2012-03-23 Thread Bob Sneidar
Look up "throw" in the dictionary. Apparently you can use it with or without a try/catch structure. It's a way to generate an error outside the scope of engine generated script errors. try if not (there is a file "/Users/MyProfile/Library/Preferences/MyAppCriticalPreferences.plist") then

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 Jim Hurley
ieder > To: use-livecode@lists.runrev.com > Subject: Re: Need an example of how to use "try" and "catch" > Message-ID: <33780499187.2012033...@ahsoftware.net> > Content-Type: text/plain; charset=us-ascii > > Jacque- > > Thursday, March 22, 2

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. --

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 L

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

2012-03-22 Thread Jim Hurley
Code > Subject: Re: Need an example of how to use "try" and "catch" > Message-ID: <4f6b6211.3070...@hyperactivesw.com> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > On 3/22/12 12:21 PM, Jim Hurley wrote: >> Thanks Peter. >>

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 l

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 th

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

2012-03-22 Thread Pete
Sorry to keep this thread going but I'm trying to figure out if I should be using try/catch more, particularly for database calls. As far as I know, you can tell if any of the standard rev db calls fail by checking their returned value or the result. Are there circumstances where that's not the c

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 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 roun

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

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 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

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 comman

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 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 >

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 p

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 num

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: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 objec

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 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: > > T

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 > To: How to use LiveCode > Subject: Re: N

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 a

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: > >>

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 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 catch tError end try and the error

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 proce

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 &

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] o

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" comma