×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Transferring the names of text files to a *.dbf file

Transferring the names of text files to a *.dbf file

Transferring the names of text files to a *.dbf file

(OP)
I have a directory in which a text file is added every week.
It will look like that:
2401.txt
2402.txt
2403.txt etc.

I would like to automatically transfer this information vertically into a column of the Mydir (c) field with the file names of the *.txt files in a VFP file (mydbf.dbf).

So that's how
Mydbf
Field name Mydir:


2401.txt
2402.txt
2403-txt
etc.
Of course I can
DIR *.txt TO mydir.xxx
code, then I first receive a text file with all the names
but it also contains all the bytes below and the file names are next to each other - so difficult to read because I only need the file names for my Mydbf.dbf.
and inserting via filetostring only gets a few of the textfile-names as the string gets to long with that structure.
Is there an another or easier way?

Thanks
Klaus


Peace worldwide - it starts here...

RE: Transferring the names of text files to a *.dbf file

ADIR(), Klaus, there is ADIR to create an array and then you can append from that array into a DBF.

So that's a two-liner (if you don't count the cursor creation), as your DBF already exists:

CODE

Create Cursor directoryfiles (cFilename c(254), nSize I, dLastModifieddate D, cLastmodifiedTime C(8))

ADir(laFiles,Home()+'*.txt')
Append From Array laFiles 

Chriss

RE: Transferring the names of text files to a *.dbf file

(OP)
Thanks Chriss,
that is exactly what I want.
Regards
Klaus

Peace worldwide - it starts here...

RE: Transferring the names of text files to a *.dbf file

(OP)
Chriss - what is the meaning of the nSize integer field?

Peace worldwide - it starts here...

RE: Transferring the names of text files to a *.dbf file

Size means how large a file is, in bytes.

It's documented in the help of ADIR, what the array contains.

If you only need the file names, you can also create a DBF with only the first column, the array has even one more column about file attributes, so I just thought I demonstrate both that
a) you get more info from ADIR
b) you don't need to define a DBF with all columns in the array, appending an array just starts with the first array column and the first DBF column and will also not error if the datatypes don't match, you just won't get values correctly and drop surplus elements, but you're also not forced to use them up. But define the fields of a DBF according to the array definition and you get all info.

Chriss

RE: Transferring the names of text files to a *.dbf file

(OP)
Thanks again, Chriss
and it's ok that you demonstrated more because
in this case the NSize is useful, as I can see that they are all similar - and that should be the case as the files contain table of contents of a magazine.

Klaus

Peace worldwide - it starts here...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close