Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Anil Sharma
  Where is Anil Sharma?
 ludhiana
 India
 Anil Sharma
 To: Cecil Champenois
  Where is Cecil Champenois?
 Little Elm
 Texas - United States
 Cecil Champenois
 Tags
Subject: RE: SCAN WHILE not working with conditions
Thread ID: 331077 Message ID: 331101 # Views: 42 # Ratings: 1
Version: Visual FoxPro 9 SP2 Category: Databases, Tables and SQL Server
Date: Monday, December 26, 2011 8:19:52 PM         
   


> SCAN WHILE seems to be unable to do the job with conditions added to it. This is part of a previous posting where I was using LOCATE WHILE which wasn't cutting it either. The below SCAN WHILE is never true, although the data says it should be.
>
> Is there some known bug, or deficiency, with SCAN WHILE?
>
>
> IF m.CHILD AND SEEK(m.GrpID+m.GrpNum, "GRPEXTDP", "FULL_KEY")
> 	SELECT GRPEXTDP
> 	SCAN WHILE GrpExtDP.GrpID+GrpExtDP.GrpNum=m.GrpID+m.GrpNum AND ;
> 		EVALUATE([LEFT(RelateCd, 1) $ "C,D"] + lcCondition)
> 

> I am going to try the following:
>
> IF m.CHILD AND SEEK(m.GrpID+m.GrpNum, "GRPEXTDP", "FULL_KEY")
> SELECT GRPEXTDP
> SCAN WHILE GrpExtDP.GrpID+GrpExtDP.GrpNum=m.GrpID+m.GrpNum
> IF EVALUATE([LEFT(RelateCd, 1) $ "C,D"] + lcCondition)
> * List variables and their sources.
> m.Seq=GRPEXTDP.Seq && Dependent's Sequence #
> IF .chk9DigitSSN.Value = 1 && Show all 9-digits of Dependent's SSN.
> m.SSN=tmpResults.SS_Number && Employee's SSN
> ELSE
> * Employee's Last 4-digits of SSN.
> m.SSN=SUBSTR(tmpResults.SS_Number, 6, 4)
> ENDIF
> m.LastName =tmpResults.LastName && Employee's Surname
> m.FirstName=tmpResults.FirstName && Employee's First Name
> m.DepLName =GRPEXTDP.LastName && Dependent's Surname
> m.DepFName =GRPEXTDP.FirstName && Dependent's First Name
> m.Eff_Date =GRPEXTDP.EffDate && Dependent's Effective Date
> m.TermDate =GRPEXTDP.TermDate && Dependent's Term Date.
> m.Relation =GRPEXTDP.Relation && Daughter, Son, Child
> INSERT INTO cDetail FROM MEMVAR
> ENDIF
> ENDSCAN
> ENDIF
> > Cecil Champenois, Jr.

the condition you use in while should equal to the database order so use scan for instead of scan while.
see the example what i mean.

CREATE CURSOR JUNK ( ID I)

INSERT INTO JUNK VALUES (1)
INSERT INTO JUNK VALUES (1)
INSERT INTO JUNK VALUES (1)
INSERT INTO JUNK VALUES (2)
INSERT INTO JUNK VALUES (2)
INSERT INTO JUNK VALUES (1)
INSERT INTO JUNK VALUES (2)
INSERT INTO JUNK VALUES (2)

SELECT JUNK
LOCATE

lnCounter = 0

SCAN WHILE ID = 1
lnCounter = lnCounter + 1
ENDSCAN
=MESSAGEBOX(lnCounter)


So where while found .f. it will exit the loop.


Anil


Accounting Software

Web Development

Accounting, Inventory, Hotel Management, Restaurant Kot Billing, MLM, Excise Accounting and much much more!.
My Blog

ENTIRE THREAD

SCAN WHILE not working with conditions Posted by Cecil Champenois @ 12/26/2011 4:35:13 PM
RE: SCAN WHILE not working with conditions Posted by Mustapha Bihmouten @ 12/26/2011 4:57:18 PM
RE: SCAN WHILE not working with conditions Posted by Cecil Champenois @ 12/26/2011 5:04:12 PM
RE: SCAN WHILE not working with conditions Posted by Mustapha Bihmouten @ 12/26/2011 5:34:11 PM
RE: SCAN WHILE not working with conditions Posted by Cecil Champenois @ 12/26/2011 5:46:57 PM
RE: SCAN WHILE not working with conditions Posted by Mustapha Bihmouten @ 12/27/2011 11:34:01 AM
RE: SCAN WHILE not working with conditions Posted by Martin Krivka @ 12/27/2011 12:57:21 PM
RE: SCAN WHILE not working with conditions Posted by Mustapha Bihmouten @ 12/27/2011 1:41:37 PM
RE: SCAN WHILE not working with conditions Posted by Martin Krivka @ 12/27/2011 1:56:58 PM
RE: SCAN WHILE not working with conditions Posted by Anil Sharma @ 12/27/2011 1:59:29 PM
RE: SCAN WHILE not working with conditions Posted by Mustapha Bihmouten @ 12/27/2011 2:27:28 PM
RE: SCAN WHILE not working with conditions Posted by tushar @ 12/27/2011 2:40:27 PM
RE: SCAN WHILE not working with conditions Posted by Martin Krivka @ 12/27/2011 4:41:41 PM
RE: SCAN WHILE not working with conditions Posted by tushar @ 12/26/2011 7:42:37 PM
RE: SCAN WHILE not working with conditions Posted by Anil Sharma @ 12/26/2011 8:19:52 PM