Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Brad Schulz
  Where is Brad Schulz?
 San Carlos
 California - United States
 Brad Schulz
 To: bryan wetton
  Where is bryan wetton?
 Morphett Vale
 Australia
 bryan wetton
 Tags
Subject: RE: opening multiple tables in one routine
Thread ID: 209088 Message ID: 209359 # Views: 2 # Ratings: 0
Version: Visual FoxPro 9 Category: General VFP Topics
Date: Saturday, December 27, 2008 6:59:58 PM         
   


> Thanks for the code Brad.
>
> I have needed to alter it somewhat as it wasn't quite what I needed.
>
> The required tables are in the 'master' app's project folder in My Documents
>
> I have the table listing the required tables in my app's program folder.
>
> I use a temp folder such as C:\Documents and Settings\bryan\Application Data\tagwiz\
>
> I have a third column for the required new name - the second column has another reference
>
> so I need the copied files in that temp folder - but I am not getting a copy of the table in the temp folder. I have tried two methods.
>
> Here is my code
>
>
> 
> Set Default To (mysystempath) && my app program folder
> 
> Select * From TMGTables Into Array laTableInfo
> *
> *  laTableInfo[] is a 3-dimensional array
> *  that contains the Original Table Name and the Name of the Copy...
> *
> * So, for example...
> *   laTableInfo[1,1]="TEMP_C"
> *   laTableInfo[1,3]="TEMP_CC"
> 
> For xx=1 To Alen(laTableInfo,1)
> 	For lnExt=1 To 3
> 		lcExt=Icase(lnExt=1,".DBF",lnExt=2,".FPT",".CDX")
> 		If File(Alltrim(laTableInfo[xx,1])+lcExt)
> 			lcOldfilename = Alltrim(laTableInfo[xx,1])+lcExt
> 			lcNewfilename = (mydatapath)+Alltrim(laTableInfo[xx,3])+lcExt
> 			logging(lcOldfilename)
> 			logging(lcNewfilename)
>                         && first alternative method
> 			COPY FILE(lcOldfilename )TO (lcNewfilename)
>                         && original method
> 			CopyFile(lcOldfilename,lcNewfilename,0)
> 		Endif
> 	Endfor
> 	Set Default To (mydatapath)
> 
> *  open dbf
> 
> 		If Not Used(lcNewfilename )
> 			Use (lcNewfilename) In 0
> 		Endif
> 		Set Default To (mysystempath)
> 
> Endfor
> 
> Do openings - to test for open tables at a point in the code - writes to log
> 
> 
> 

>
> The output to the log file is
>
> 5:39:01 PM sample_$.DBF
> 5:39:02 PM C:\Documents and Settings\bryan\Application Data\tagwiz\temp_LL.DBF
>
> all the way to
>
> 5:56:19 PM sample_t.CDX
> 5:56:19 PM C:\Documents and Settings\bryan\Application Data\tagwiz\temp_TT.CDX
> 5:56:19 PM File Open in Area 1 is TAGS 84
> 5:56:19 PM File Open in Area 3 is MYPATHS 1
> 5:56:19 PM File Open in Area 4 is TMGTABLES 16 - list of tables to be copied
>
> times are for different runs.
>
> Hoping you can see where I am in error...
>
> Merry Christmas.
>
>
> -Bryan



In looking at the output of your log file, I would guess that the file IS being COPIED okay. But the copied file is not being opened. I think that's because of your test with the USED() function.

The USED() function takes as an argument an ALIAS name, and NOT a FILE name.

Try changing the USED line so that it says:

IF USED(JUSTSTEM(lcNewFilename))


--Brad

ENTIRE THREAD

opening multiple tables in one routine Posted by bryan wetton @ 12/24/2008 6:58:11 AM
RE: opening multiple tables in one routine Posted by Brad Schulz @ 12/24/2008 8:09:38 AM
RE: opening multiple tables in one routine Posted by bryan wetton @ 12/25/2008 8:29:48 AM
RE: opening multiple tables in one routine Posted by Brad Schulz @ 12/27/2008 6:59:58 PM
RE: opening multiple tables in one routine Posted by bryan wetton @ 12/28/2008 2:48:51 AM
RE: opening multiple tables in one routine Posted by Stefan Wuebbe @ 12/28/2008 10:26:40 AM
RE: opening multiple tables in one routine Posted by bryan wetton @ 12/29/2008 12:37:26 PM
RE: opening multiple tables in one routine Posted by Brad Schulz @ 12/29/2008 7:26:41 PM
RE: opening multiple tables in one routine Posted by Stefan Wuebbe @ 12/29/2008 7:40:52 PM
RE: opening multiple tables in one routine Posted by bryan wetton @ 12/30/2008 7:59:40 AM
RE: opening multiple tables in one routine Posted by bryan wetton @ 12/30/2008 7:53:24 AM
RE: opening multiple tables in one routine Posted by Stefan Wuebbe @ 12/29/2008 7:38:40 PM
RE: opening multiple tables in one routine Posted by Jyothish KV @ 12/24/2008 8:49:56 AM
RE: opening multiple tables in one routine Posted by Andy Kramek @ 12/24/2008 12:20:17 PM