Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Tony Vignone
  Where is Tony Vignone?
 St Augustine
 Florida - United States
 Tony Vignone
 To: Greg Green
  Where is Greg Green?
 
 Georgia - United States
 Greg Green
 Tags
Subject: RE: LOCATE FOR
Thread ID: 416437 Message ID: 416506 # Views: 29 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Databases, Tables and SQL Server
Date: Tuesday, December 30, 2014 3:27:40 PM         
   


> >
> > You forgot to re-SELECT KMartSearsFiles2012 after the LOCATE
> > SCAN and LOCATE require CURRENT ALIASES!
> >
> >
SELECT KMartSearsFiles2012
> > SCAN
> > 	* Get the string. We will need to parse this string out.
> > 	* The file names are separated with":" at the beginning,
> > 	* and the end of each file.
> > 	lcAttachment=":" + ALLTRIM(KMartSearsFiles2012.FileName) + ":"
> > 	lcMessageDate=KMartSearsFiles2012.Msg_Dt
> > 	SELECT MySQL_Emails
> > 	LOCATE FOR ;
> > 		MySQL_Emails.Recvd_Dt = lcMessageDate AND ;
> > 		lcAttachment $ MySQL_Emails.Attachment
> > 	IF FOUND()
> > 		REPLACE MySQL_Emails.lFound WITH .T.
> > 	ENDIF
> > 	SELECT KMartSearsFiles2012        && <=============================
> > ENDSCAN
> > 

> > However, better still GO TOP, EOF() and SKIP do NOT require current aliases. That is why I always prefer DO WHILE loops so I don't ever have to worry about the alias being current.
> >
> >
SELECT MySQL_Emails
> > GO TOP in "KMartSearsFiles2012"
> > DO WHILE NOT EOF("KMartSearsFiles2012")
> > 	* Get the string. We will need to parse this string out.
> > 	* The file names are separated with":" at the beginning,
> > 	* and the end of each file.
> > 	lcAttachment=":" + ALLTRIM(KMartSearsFiles2012.FileName) + ":"
> > 	lcMessageDate=KMartSearsFiles2012.Msg_Dt
> > 	LOCATE FOR ;
> > 		MySQL_Emails.Recvd_Dt = lcMessageDate AND ;
> > 		lcAttachment $ MySQL_Emails.Attachment
> > 	IF FOUND()
> > 		REPLACE MySQL_Emails.lFound WITH .T.
> > 	ENDIF
> > 	SKIP IN "KMartSearsFiles2012"
> > ENDDO 

> >
> > Tony
>
> Not true on the current alias for the SCAN loop. You really don't have to SELECT again the alias. The SCAN loop once started, "knows" which alias to act on. However, LOCATE does not and only acts on the current alias; so you have to SELECT first as Cecil did. The FOUND() command by default acts on the current alias but you can explicitly direct this to an alias by FOUND('MyAlias').

Thanks, did not know that.

Tony

ENTIRE THREAD

LOCATE FOR Posted by Cecil Champenois @ 12/29/2014 6:34:17 PM
RE: LOCATE FOR Posted by Pete Sass @ 12/29/2014 7:11:17 PM
RE: LOCATE FOR Posted by Cecil Champenois @ 12/29/2014 9:38:00 PM
RE: LOCATE FOR Posted by Greg Green @ 12/29/2014 9:57:36 PM
RE: LOCATE FOR Posted by Pete Sass @ 12/29/2014 11:16:15 PM
RE: LOCATE FOR Posted by Mike Yearwood @ 12/30/2014 3:49:07 PM
RE: LOCATE FOR Posted by Pete Sass @ 12/30/2014 6:18:31 PM
RE: LOCATE FOR Posted by Mike Yearwood @ 12/30/2014 6:55:18 PM
RE: LOCATE FOR Posted by Mike Yearwood @ 12/29/2014 8:30:51 PM
RE: LOCATE FOR Posted by Cecil Champenois @ 12/29/2014 9:35:06 PM
RE: LOCATE FOR Posted by Tony Vignone @ 12/29/2014 9:03:34 PM
RE: LOCATE FOR Posted by Greg Green @ 12/29/2014 10:03:17 PM
RE: LOCATE FOR Posted by Tony Vignone @ 12/30/2014 3:27:40 PM
RE: LOCATE FOR Posted by David Myrick @ 12/29/2014 10:21:05 PM
RE: LOCATE FOR Posted by Jun Tangunan @ 12/30/2014 2:23:08 AM