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

Modify records based on external file

Status
Not open for further replies.

djTechZombie

Programmer
May 18, 2016
2
US
I am working on updating some old prg files to process a particular client's data. As the job has grown more complex over the years, I have had to manually edit the files for each job to update things such as version number (job 123456 v01, v02, etc) and whether or not certain prgs were run. I've decided to create a Form and include updated versions of each of the programs, and (almost) everything is working great.

The problem I am having is that every 1 out of 20 or so jobs needs to be coded to split by version based on a field in the data. I have been manually adding a REPLACE ALL command at the bottom of the prg to accomplish this. I am trying to figure out a way that I can import an external file containing the criteria.

My thought was to use an array and load a csv file with the Code and Ver, but I have been having issues getting it to work.

I've been having to use C# knowledge combined with VFP help files and internet resources to give myself a crash course in vfp9 (I've been using VFP for 8 years or so, but never programmed anything more than "REPLACE ALL FIELD1 WITH FIELD2 FOR FIELD1 = ' '"

Any ideas? Am I even on the right track?

I need to be able to update the matching criteria on a job by job basis, so a creating a compiled prg isn't feasible. I would like a stand-alone exe file that other programmers can use while I am out of the office.

Thanks

**********************************************************
DECLARE aSplit [50,2]

CLOSE DATABASES
CLEAR

CREATE CURSOR cSplit;
(CellCode C(5), Ver C(3))

select cSplit
append from VerSplit.txt type csv &&Comma delimited file containing criteria

COPY TO ARRAY aSplit

USE Laser && DBF file being manipulated

nSplit = ALEN(aSplit, 1)

FOR nCount = 1 to nSplit
REPLACE ALL FILLER11 WITH aSplit[1,2] FOR LETTER_CD = aSplit[1,1]
ENDFOR

************************************************************************************
 
Overall I don't quite understand you.

You say you have to maintain some vertical market software for different customers and the individual customizations are somewhat done by v1,v2,v3 prgs so each customer has a certain combination of versions of PRGs active for him. I f that's the case I'd perhaps go about this different, but I'm quite sure I have a misunderstanding about this.

In detail I understand from your code you have to do some replaces based on a control file specifying some trigger value (loked for in LETTER_CD) and a value to fill in. If that's what you mainly do to earn a living, I partially congratulate and partly am sorry for you.

Why use a CSV file for such a replacement? Why not use a DBF, when you deal with DBFs? Assume a translate DBF contains the same named fields. The UPDATE you'd need is:
Code:
UPDATE laser.DBF SET flller11 = translate.filler11 
FROM translate.DBF WHERE Laser.letter_cd = translate.letter_cd

That's replacing all your code, you either CD to some folder or USE the DBFs in further previous lines, but mainly you just need one UPDATE-SQL for this.

Bye, Olaf.

I'm quite sure this is just a corner of your work done as c# dev for this software, so don't take my being sorry for you too seriuos. I'm quite sure you need something more general than an UPDATE-SQL, so please tell about the problem from a more general perspective, and this might help get this problem solved on a higher level much more to the point.
 
Thank you very much. That did the trick. I receive an Excel file from the client that I can use to create the translate dbf. It also has the added bonus of not requiring an additional check as to whether or not the job needs to be split as well as extra prgs for split/non-split.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top