Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Re-try with TRY/CATCH
Message
 
 
To
16/12/2008 03:16:54
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01367724
Message ID:
01367770
Views:
10
>>Something like
>>
>>FOR lnI = 1 TO 2
>>	TRY
>>		&tcSql
>>	CATCH TO loEx
>>		_CLIPTEXT = m.tcSql
>>		IF lnI = 1 AND loEx.ERROR = 108  && File is in use by another user
>>
>>			DECLARE INTEGER Sleep IN Win32API INTEGER cMilliseconds
>>			=Sleep(0.5*1000) && wait half a second
>>** we're going to re-try
>>		ELSE
>>                                               * the normal catch code
>>                                               lnI = 10 && to fall out the loop
>>                                          ENDIF
>>                         ENDTRY
>>NEXT
>
>(1) What if there's no error ?
>(2) I prefer EXIT instead of lnI = 10
> - more readable
> - what if you decide to try 10 or 15 times (or step -1) and forget to change lnI = 10 ?

Good point about no error! I forgot about it. I guess I need to add some extra check in FINALLY clause for this too.

I don't like EXIT in principle :)
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform