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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help about folder en files...

Status
Not open for further replies.

bigdad

Programmer
Jul 17, 2001
34
VE
Hi every body, I´ve a folder "c:\myfolder" and in this folder I´ve some free tables "c:\myfolder\mytable1.dbf", "c:\myfolder\mytable2.dbf", etc, whell, I need search in each table some register and replace or insert in a table in my principal database. My question is: Is posible locate this register in all tables into "c:\myfolder" at same time???

I hope someone can helpme

Bigdad
 
bigdad

Create an array of the tables in the directory:
SET DEFAULT TO C:\myFolder
nCount = ADIR(a_MyTable,"*.dbf")

And the loop through the array
Code:
SET DEFAULT TO c:\slp\dbfs
nCount = ADIR(a_Mytables,"*.dbf")
FOR i = 1 TO nCount
  IF !EMPTY(a_myTables[i,1])
     LOCAL tName
     STORE a_myTables[i,1] TO tName
     USE (tName) SHARED AGAIN IN 0
     SELECT (tName)
     && Do what you have to do here
   ENDIF
NEXT
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Of course! There's always a way! It just depends on whether it would take more coding time than manual time as to whether you want to go about it.

If you are going to look in a specific column in all the tables for a certain item, you could do something like:
Code:
*... get an array of tables
nHowMany = ADIR(aTables, '*.DBF')

*... walk throught the array
FOR ii = 1 TO nHowMany
   USE (aTables[ii, 1]) ALIAS tmptable
   *... just in case you grab a table without 
   *...  your particular search field in it
   IF TYPE('tmptable.SearchField') # 'U' 
      *... LOCATE the item, or SEEK if you have an index
      LOCATE FOR tmptable.SearchField = 'Whatever'
      IF FOUND()
         SCATTER MEMVAR
         REPLACE SomeTable.SomeField WITH ;
            tmptable.SearchField
      ENDIF
   ENDIF
NEXT

Now if you're going to look for the value in an unknown field, that's a different scenario. You will have to create an array of field names and walk through them, doing a locate, seek, SELECT SQL or whatever for each column.
Dave S.
 
DSummZZZ

Looks like Mike and I are on the same page

Same page, same book :) Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
THANK´S you guy, this really helpme. I was thinking do it with DIR c:\myfolder\*.DBF TO FILE MYFILE.TXT, then pass this .txt file to .dbf file, all of this just to get the name of all my tables, then pass the nametable to a variable(varnametable=nametable) and then select with select while !eof(). This is to much complicated but this was just the only way that I had. Really thank´s. Excuse my english but I just talk spanish because I´m from Venezuela
 
THANK´S you guy, this really helpme. I was thinking do it with DIR c:\myfolder\*.DBF TO FILE MYFILE.TXT, then pass this .txt file to .dbf file, all of this just to get the name of all my tables, then pass the nametable to a variable(varnametable=nametable) and then select with select while !eof(). This is to much complicated but this was just the only way that I had. Really thank´s. Excuse my english but I just talk spanish because I´m from Venezuela

Bigdad
 
No worries. Your english is much better than my spanish.
Dave S.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top