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

files in a table

Status
Not open for further replies.

alisaif

ISP
Apr 6, 2013
418
AE
Hi,

I want to save files names (*.scx) and (*.sct) along with directory name in a table. How can I do so?
Please help!

Saif
 
You are not very clear in what you want to accomplish. Are your file names and directories already available in your program? Or are you wanting to access file names somewhere on a disc?

If the former, just save the names to a table like any other strings.

If the latter, use [tt]ADIR()[/tt] to scrape a list from the disc into an array, then process like any other strings.

Visual FoxPro [tt]ADIR()[/tt] function

mmerlinn


Poor people do not hire employees. If you soak the rich, who are you going to work for?

"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Raymond
 
If you have these form files in your project you already have a table with this data, the pjx file. The Homedir field has the project home directory in the first record and the Name field has file names with path relative to this homedir.

Besides you can get file names from a for loop
Code:
FOR EACH loFile in _vfp.activeproject.Files. 
? loFile.Name
ENDFOR

And you know how to store data into a table.

Bye, Olaf.
 
Thanks for the reply!

I did this:

CLOSE DATABASES
CREATE CURSOR filnam (filename c(50))
SET DEFAULT TO d:\vtts\forms
gnfrmnumber = ADIR(gaDatabase, '*.scx') && Create array

CLEAR
FOR nCount = 1 TO gnfrmnumber && Loop for number of databases
SELECT filnam
APPEND BLANK
REPLACE filename WITH gaDatabase(nCount,1) && Display database names
ENDFOR

SET DEFAULT TO d:\vtts

Saif
 
Have you looked into the data?
ADIR returns file names only. You said you wanted to store it "along with directory name".
As that is d:\vtts\forms you have to add "d:\vtts\forms"+array element value.

Bye, Olaf.
 
Hi,

In addition to that how can I save only directory name like:

d:\vtts
d:\vtts\data
d:\vtts\forms
d:\vtts\libs
..
..
etc in a cursor?

CREATE CURSOR dirnam (Dirname c(75))

Thanks !

Saif
 
Use JUSTPATH(fullfilename) if you process file names.

If you need to determine subdirectories CD into the main directory and use ADIR() with "D" in the cAttribute parameter. That will put Directories in the result array additional to files. The Directories will have a D as rightmost character in their 4th column, as described in the structire of the result array.

Bye, Olaf.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top