Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating tables

Status
Not open for further replies.

StacyStacy

Programmer
Apr 16, 2003
60
US
How do I update tables checking the "modified" date in the file manager in the main working directory vs. the "modified" date in the reports folder in another directory?

EX:
here's the path to the main systems files:
c:\abc\ourdata
here's the path to the reports menu in another directory:

f:\xyz\etdrpts
Thanks a million!
 
Try something like:
Code:
STORE "c:\abc\ourdata\SomeFile.DBF" TO cOurs
STORE "f:\xyz\etdrpts\SomeFile.DBF" TO cTheirs
STORE ADIR(aOurs, cOurs) TO nOurs
STORE ADIR(aTheirs, cTheirs) TO nTheirs

IF nOurs = 0 .OR. nTheirs = 0
   WAIT WINDOW 'Files not found' TIMEOUT 3
ELSE
   WAIT WINDOW ;
      IIF(aOurs[1, 3] > aTheirs[1, 3] , cOurs, cTheirs) + " is newer." ;
      TIMEOUT 5
ENDIF


-Dave Summers-
[cheers]
Even more Fox stuff at:
 
I need to check to see if the dbf's has the latest "modification" dates in the f:\xyz\ directory. If not, then I will copy the dbf's to xyz directory. I just don't know how to write the code to check to see if it's the latest info.

Thanks,
 
By using ADIR() you can put information about a directory's files (or single file) into a sepcified array. Part of that information is the file's date.

mcDir_1 = "C:\ABC\"
mcDir_2 = "C:\XYZ\"

=ADIR(aryDir_1, mcDir_1 + "\MyFile.DBF")
=ADIR(aryDir_2, mcDir_2 + "\MyFile.DBF")

mdDate1 = aryDir_1(1,3)
mdDate2 = aryDir_2(1,3)

Look at the Foxpro Help file for ADIR() to get more specific information.

Good Luck,


JRB-Bldr
VisionQuest Consulting
Business Analyst & CIO Consulting Services
CIOServices@yahoo.com
 
Thanks, but I failed to tell everyone that I am using, get this, FoxPro 2.6.

Here's my code that I have so far:
CASE m.doit = 6

=adir(prod,'c:\bashtemp\jt1.dbf')
=adir(rpts,'jt1.dbf')
?prod(1,3) > rpts(1,3)
* disp memo like prod
* disp memo like rpts

IF rpts(1,3) < prod(1,3)
WAIT WINDOW "DATA NEEDS TO BE REFRESHED STACY!" TIMEOUT 2
use jt1
COPY TO J:\TESTING\ETDRPTS
WAIT WINDOW "Dbf's have been refreshed. Please Continue Compiling Reports"

ELSE
WAIT WINDOW "Data is already refreshed. Please Continue Compiling Reports"

ENDIF

What do you think? It does not copy the dbfs to the testing site. Why? what did I do wrong?
 
I think that the problem is with the "USE JT1 ... and COPY TO ..." Apart from not being clear (by the code segment shown) which JT1 is used, we dont know the locking status.

Now apparently, this is a batch job. So you might as well:

CLOSE all the files and
COPY FILE not forgetting the associaed indices and memos.

Hope this helps.
End.
 
Thanks. I figured it out and have tested it. It 1/2 way works. Some files that were not up-to-date, did not copy and update the older files. Here's the code I used:

(REMEMBER, I AM USING FOXPRO 2.6)

DO CASE
CASE m.doit = 1

=adir(prod,'h:\etdcode\wia_bash\jt1.dbf')
=adir(rpts,'jt1.dbf')
?prod(1,3) > rpts(1,3)

IF rpts(1,3) < prod(1,3)
WAIT WINDOW "The BASH Databases Needs to Be Updated. Please Press Any Key To Continue." TIMEOUT 4

CLOSE DATABASES

WAIT WINDOW "Please Wait ..."

COPY FILE h:\etdcode\wia_bash\jt1.dbf to j:\testing\etdrpts\jt1.dbf
COPY FILE h:\etdcode\wia_bash\jt1.cdx to j:\testing\etdrpts\jt1.cdx

COPY FILE h:\etdcode\wia_bash\jt2.dbf to j:\testing\etdrpts\jt2.dbf
COPY FILE h:\etdcode\wia_bash\jt2.cdx to j:\testing\etdrpts\jt2.cdx

COPY FILE h:\etdcode\wia_bash\act_mstr.dbf to j:\testing\etdrpts\act_mstr.dbf
COPY FILE h:\etdcode\wia_bash\act_mstr.cdx to j:\testing\etdrpts\act_mstr.cdx

COPY FILE h:\etdcode\wia_bash\suppout.dbf to j:\testing\etdrpts\suppout.dbf
COPY FILE h:\etdcode\wia_bash\suppout.cdx to j:\testing\etdrpts\suppout.cdx

COPY FILE h:\etdcode\wia_bash\ythgoals.dbf to j:\testing\etdrpts\ythgoals.dbf
COPY FILE h:\etdcode\wia_bash\ythgoals.cdx to j:\testing\etdrpts\ythgoals.cdx

COPY FILE h:\etdcode\wia_bash\wia_mstr.dbf to j:\testing\etdrpts\wia_mstr.dbf
COPY FILE h:\etdcode\wia_bash\wia_mstr.cdx to j:\testing\etdrpts\wia_mstr.cdx

COPY FILE h:\etdcode\wia_bash\nonwia.dbf to j:\testing\etdrpts\nonwia.dbf
COPY FILE h:\etdcode\wia_bash\nonwia.cdx to j:\testing\etdrpts\nonwia.cdx

WAIT WINDOW "The BASH Databases Has Been Updated. Please Continue Compiling Reports." TIMEOUT 3

ELSE
WAIT WINDOW "The BASH Databases Has Already Been Updated. Please Continue Compiling Reports" TIMEOUT 3

ENDIF
 
You will need to verify no one else has the tables open. Maybe put some ON ERROR code in there or USE them exclusive to see if you have access, then close them and copy.
Make sure you have all the file names correct too.

(REMEMBER, I AM USING FOXPRO 2.6)

(The code example I sent was written with FoxPro 2.5)

-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top