procedure TPrint.Timer1Timer(Sender: TObject);
var
searchResult : TSearchRec;
myfile, myfile1: text;
found : boolean;
sl : TStringList;
s: string;
i:integer;
count:integer;
File1, File2: TextFile;
vCntr : integer;//nothing new just a counter.
begin
SetCurrentDir('C:\Users\Public\print\check');
if findfirst('*', faAnyFile, searchResult) = 0 then
begin
repeat
statictext4.Caption:=searchResult.Name;
until FindNext(searchResult) <> 0;
end;
if (searchResult.Name<> '.') and (searchResult.Name<> '..') then
begin
if FileExists('C:\Users\Public\print\checkall\all.csv') then
begin
count := 0;
found := false;
sl := TStringList.Create;
filename1 := StaticText4.Caption;
filename2 := copy(filename1,0,(length(filename1)-4));
try
sl.LoadFromFile('C:\Users\Public\print\checkall\all.csv');
for vCntr := 0 to sl.count -1 do begin //use a for loop instead.
if Pos(filename2, sl[Vcntr])<>0 then begin
//read the first line from the other file in the line variable
sl[Vcntr] := line; //replace the existing line with the new
//read the second line from the other file in the line variable
sl[vCntr+1] := line; //replace the second line with the new
//read the third line from the other file in the line variable
sl[vCntr+2] := line; //replace the third line with the new
//read the fourth line from the other file in the line variable
sl[vCntr+3] := line; //replace the fourth line with the new
//read the fifthline from the other file in the line variable
sl[vCntr+4] := line; //replace the fifth line with the new
break; //exit the for loop;
end;
end;
sl.savetofile('C:\Users\Public\print\checkall\all.csv');//replace the file data with the new data.
finally
sl.Free;
end;
end;
end;
begin
SetCurrentDir('C:\Users\Public\print\check');
if findfirst('*', faAnyFile, searchResult) = 0 then
begin
repeat
statictext4.Caption:=searchResult.Name;
until FindNext(searchResult) <> 0;
end;
if (searchResult.Name<> '.') and (searchResult.Name<> '..') then begin
//SERIAL MATHERBOARD
filename := StaticText4.Caption;
StaticText5.Caption:=filename;
if FileExists(statictext4.Caption) then
begin
assignfile(File1,'C:\Users\Public\print\check\'+statictext4.Caption);
assignfile(File2,'C:\Users\Public\print\checkall\all.csv');
reset(File1); //open for read;
append(File2); //asumes File2 can be written to, puts filepointer at end of the file
while not Eof(File1) do
begin
readln(File1,S); //read a line frome file1
writeln(File2,S); //write the line to file2
end;
CloseFile(File1);
CloseFile(File2);
Erase (File1); // delete file
AssignFile(F, 'C:\Users\Public\print\checkall\all.csv');
Append(f);
CloseFile(F);
end;
end;
end;
end;