Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RETRY command
Message
From
18/11/2015 12:59:21
 
 
To
18/11/2015 11:27:25
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01627594
Message ID:
01627602
Views:
57
That's definitely a novel use for RETRY -- normally I'd only use it within the context of an ON ERROR trap. As Tore mentioned, most cases where one might use ON ERROR traps, a TRY .. CATCH .. ENDTRY block would probably be a better choice (unless of course you're using something older like VFP6). Yep, I've seen and used code where there are chunks of code that look like the following in older versions of FoxPro:
<i>...</i>
nRetryCnt = 0
lcOrgTrap = ON("ERROR")
ON ERROR DO LocalTrap WITH ERROR(),MESSAGE(),MESSAGE(1),PROGRAM(),LINENO()
... some code ...
ON ERROR &lcOrgTrap.
.
.
.
PROCEDURE LocalTrap
    PARAMETERS nErrNum,cErrMsg,cErrTxt,cErrProg,nErrLine

    IF INLIST(m.nErrNum,  { list of errors where a retry normally will recover } ) THEN
        nRetryCnt = m.nRetryCnt + 1
        IF m.nRetryCnt < 5 THEN
            RETRY
        ENDIF
    ENDIF
    IF INLIST(m.nErrNum,  { list of errors I want to ignore } ) THEN
        RETURN
    ENDIF
    *... some error handling code..
ENDPROC
>Just curious,
>
>I was just experimenting and noticed this.
>
>If a subroutine is called as a procedure with a DO statement, the RETRY statement will execute the DO statement again as expected. But if the subroutine is called as a function, the RETRY statement acts like a RETURN command. I have not found any documentation that states is the case.
>
>Does anyone have any further insight to this?
>
>Here is a Test Case that demonstrates this
>
>*-- loopless Loop
>
>SET UDFPARMS TO REFERENCE
>
>LOCAL i as Integer 
>i = 0
>
>DO LoopLess WITH i
>? i      & 10
>
>i = 0
>= LoopLess( @i )
>? i     && 1, expected 10
>
>
>*-----------
>PROCEDURE LoopLess
>	LPARAMETER j
>	LOCAL llResult as Boolean
>	llResult = .T.
>	*
>	j = j + 1 
>	IF j < 10 THEN 
>		RETRY
>	ENDIF 
>	*
>	RETURN llResult
>ENDPROC
>
>* EOF
>
Previous
Reply
Map
View

Click here to load this message in the networking platform