Dennis:
Never RETURN within a WHILE - ENDWHILE loop. Alter the code so the loop completes.
You can set your verr = 0, or break.
A good rule of thumb is always enter each block of code at one place and exit at one
place. With the IF - ENDIF block, have one RETURN at the end of the block and use code
to get to it rather than a RETURN in the middle of the block.
Hope this helps,
Jim Blackburn
Kodiak
Dennis Fleming wrote:
>
> RBWin 6.x
>
> Recent posts from Dr R (I believe), recommended that initializing VARs
> should be done outside the While loop. I've done that and also always have:
> Set WhileOpt OFF. But, the following While Loop gets bumped out in an EEP
> whereas the IF/Endif is fine. (This code checks user enters a valid date.)
>
> Example 1.
>
> SET VAR vdate = (CTXT(.#date))
> SET VAR vcdate DATE
> SET VAR verr = 1
> WHILE verr <> 0 THEN
> DIALOG "Set Completion Date to:" vdate=9 vlast 1 AT 12
> IF vlast = "[ESC]" OR vdate IS NULL THEN
> RETURN
> ENDIF
> SET VAR vcdate = .vdate
> SET VAR verr = .vderr
> ENDW
>
> Example 2.
>
> SET VAR vdate = (CTXT(.#date))
> SET VAR vcdate DATE
> LABEL AGAIN1
> DIALOG "Set Completion Date to:" vdate=9 vlast 1 AT 12
> IF vlast = "[ESC]" OR vdate IS NULL THEN
> RETURN
> ENDIF
> SET VAR vcdate = .vdate
> SET VAR verr = .vderr
> IF verr <> 0 THEN
> GOTO Again1
> ENDIF
>
> >>>>>>>>>
>
> Later in the EEP, there is another While Loop which works fine:
>
> SELECT COUNT (*) INTO xparts FROM wref WHERE tk_nbr = .tknbr
> WHILE xparts > "0" THEN
> SET VAR prnbr = pr_nbr, prqty = pr_qty IN wref WHERE tk_nbr = .tknbr +
> AND COUNT = .xparts
> SET VAR prunitp = pr_unitp IN parts WHERE pr_nbr = .prnbr
> INSERT INTO tract VALUES +
> "IS" .tksdate .prnbr .prqty .prunitp .eqnbr .xtrpo .eqacct .cfid
> SET VAR xparts = (.xparts - 1)
> ENDW
> ....
>
> Any help or ideas are appreciated.
>
> Dennis
> *****
> Dennis Fleming
> IISCO
> http://www.TheBestCMMS.com