Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Appending low level files together
Message
From
06/08/2003 12:33:48
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00817370
Message ID:
00817379
Views:
17
>Can anyone tell me how to append two files together using visual fox?
>These two files are not dbf's just plain txt files. I'm looking for
>a function that will allow me to concatenate them together without having
>to call DOS to do it.
>
>Thanks

You can do it using Low Level File Functions
ln_hnd1 = FOPEN('file1.txt',2) && Open first file
=FSEEK(ln_hnd1, 0, 2) && go bottom
ln_hnd2 = FOPEN('file2.txt',2) && Open Second File
DO WHILE .NOT. FEOF(ln_hnd2)
  =FWRITE(ln_hnd1, FREAD(ln_hnd2, 1024 *  1024))
ENDDO
=FCLOSE(ln_hnd1)
=FCLOSE(ln_hnd2)
Or you could use the FILETOSTR functios and the STRTOFILE if the files aren't too large
=STRTOFILE(FILETOSTR('file1.txt') + FILETOSTR('file2.txt'), 'file1.txt')
Charles

"The code knows no master." - Chuck Mautz
"Everybody is ignorant, only on different subjects." - Will Rogers
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform