>Garrett,
>I understand your point, and I agree that try/catch is a Huge improvement over on error and I love the concept. To me, one of the best uses for try/catch is to help me put in low level error handling in places where there is none (just the global error handler). So comparing the size of 'on error' vs 'try/catch' programs is not what I am worried about. It is the comparison of a program with very little local error handling vs one with try/catch. At this point, I believe I want to use try/catch quite alot in my programs. However, what I perceive as program bloat is concern for me.
>Though the following is not a truly 'fair' example, it is demonstrative of this point: I can do in 7 lines of code (making use of the 'useexcl' function that I wrote long ago) what might take 13 lines of code to do using try/catch. Now, if I could use a return in the catch statement, the code would be cleaner to read and take only 10 lines which would be much more to my liking.
>
>Thanks very much for your reply,
>Eddie Caldwell
>Still waiting for the light to go on in my head =)
>
>
lopenok=(useexcl('table1') and useexcl('table2') and useexcl('table3'))
>close all
>if !lopenok
> messagebox('Unable to Get exclusive use of tables')
> return
> endif
>do backups
>
>or
>
try
> use table1 excl in 0
> use table2 excl in 0
> use table3 excl in 0
>catch
> lerror=.t.
>endtry
>close all
>if lerror=.t.
> messagebox('Unable to get exclusive use of tables')
> return
> endif
>do backups
Try it like this.
TRY
USE table1 EXCL IN 0
USE table2 EXCL IN 0
USE table3 EXCL IN 0
DO backups
CATCH TO loExc
IF loExc.ErrorNo = 1705
MESSAGEBOX("Unable to get exclusive use of tables.")
ELSE
MESSAGEBOX("Unable to perform backup for unexpected reason.")
THROW loExc
ENDif
ENDtry
Agreed, that's the same number of lines as your longer example, but your shorter example has extra lines in the UseExcl function that aren't showing up there.