Source for appending File1 to File2. Hope This helps
string File1 = "x:\file1" ; Full path and name of source
string File2 = "x:\file2" ; Full path and name of target
string LineToCopy ; String used for line to copy
proc main ; Start main procedure
fopen 1 File1 read text ; Open source file
fseek 1 0 0 ; Go to start of source
fopen 2 File2 append text ; Open target file
fseek 2 0 2 ; Go to end of target
while not feof 1 ; Loop while reading source
fgets 1 LineToCopy ; Extract line from source
fputs 2 LineToCopy ; Insert line into target
endwhile ; End Loop
fclose 2 ; Save and close target file
fclose 1 ; Close source file
endproc ; End main procedure
Mr Noisy's script is correct, but you do not need the fseek commands. The fopen will automatically put the pointer at the beginning of file1 and and append command in the file2 fopen statement is enough to put the additional lines at the end. So the shorter version would be:
[tt]
string File1 = "x:\file1" ; Full path and name of source
string File2 = "x:\file2" ; Full path and name of target
string LineToCopy ; String used for line to copy
proc main ; Start main procedure
fopen 1 File1 read text ; Open source file
fopen 2 File2 append text ; Open target file
while not feof 1 ; Loop while reading source
fgets 1 LineToCopy ; Extract line from source
fputs 2 LineToCopy ; Insert line into target
endwhile ; End Loop
fclose 2 ; Save and close target file
fclose 1 ; Close source file
endproc ; End main procedure [/tt] Robert Harris
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.