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

two files to one

Status
Not open for further replies.

ketiv

Programmer
Jan 28, 2003
6
PL
Hi
My device generated data.txt file.
When I generate the report, I moving data.txt to backup\'dtos(date())'.txt file, and clearing data.txt.
In this moment I have:
1. Report from device,
2. backup file in another folder,
3. Clear data.txt - which wait for new datas.

When I do it only once by day it's no problem, but when I must do it second time by day, a have a problem with existing (backup) file.

I have a question:
How to append two files?
For example:
data.txt and 20030526.txt to new 20030526.txt

I hope that it's clear :)
 
Ketiv,

From the DOS prompt type:

COPY 20030526.TXT + DATA.TXT
It will append DATA.TXT to 20030526.TXT

COPY 20030526.TXT + DATA.TXT NEWDATA.TXT
It will create a new file NEWDATA.TXT
 
this is piece of my code:

plik0 = "pool"
plik1 = "polln"

nazwa = 'backup/'+dtos(date())

COPY &plik0 + &plik1 &nazwa
DELETE FILE &plik0
FCREATE(plik0)

plik0 - file from my device,
plik1 - some test file.

But this not working :-(
 
Easiest way (but not the most elegent) is to make a temporary table with character fields 255 wide for however wide your reports can be and then append them both in type sdf and copy them over to a new text file type sdf.

Brian
 
Yes, I know :)
Second way is check if backup file exist, open it, and copy line by line datas from source file, but I looking for easiest method. I know that is possible, but I don't know how :)
 
How about a "one liner"?
Code:
xx=strtofile(filetostr("data.txt")+filetostr("20030526.txt"), "20030526.txt")
Rick


 
Or even shorter:

xx=strtofile(filetostr("20030526.txt"), "data.txt", 1)

No need to read 'data.txt' back in.


Dave S.
[cheers]
 
Dave this gives a new Data.txt, and his original "spec" specified a new 20030526.txt file! Perhaps he wants to keep Data.txt as a base.

Rick
 
Woops! I misread the original post. I was thinking the need was to append to 'data.txt'.

So, swap them:

xx=strtofile(filetostr("data.txt"), "20030526.txt", 1)


Dave S.
[cheers]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top