Use BREAK (not RETURN) to exit the while loop.  Once you exit the while
loop, you can see (by various means) if you broke out of the loop and then
do whatever needs to be done.




-----Original Message-----
From: Dennis Fleming [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 08, 2001 3:24 PM
To: [EMAIL PROTECTED]
Subject: WHILE vs IF


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

Reply via email to