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

Extract information from within an unknown file name? 1

Status
Not open for further replies.

ssckan

Programmer
Jun 7, 2004
11
0
0
US
We receive electronic invoices from several customers into a specific directory. The file structure is consistent, but the file naming conventions are not. Inlcuded within the file, is the customer number. We currently have a clipper program listing the directory files to the screen and require the user to key in a file name. We want to write a clipper program that will scan all files within the directory and extract the customer number from within the file without user intervention. Any help would be greatly appreciated.
 
Use ADIR() or DIRECTORY() to get a list of the files in a directory in the form of an array. You can then work through them in sequence.

MEMOREAD() them one by one into a variable and then look for some sort of text identifier for the customer number using the AT() function to find the data. For example:
Text includes CUSTOMER NUMBER:123456

cCustNo := subs(cData,AT('CUSTOMER NUMBER:',cData)+16,6)

Then you can do what you want with the data

Ian Boys
DTE Systems Ltd
 
Boss is right on.

You may want to add some logic as to not read the same files over and over again, either by deleting the file once its read, setting the archive bit, or keeping track of the read files.

Good luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top