01-01-2006, 12:46 AM
Quote:It has been kindly pointed out to me that Liberty Basic does have an alternative to the PROCedures used in BBC BASIC (for Windows) needed for true Structured Programming as below. I wonder how the experts on programming view the LB wayLooks fairly straightforward.
Gordon
'copy two files into one
fileOne$ = "first.txt"
fileTwo$ = "second.txt"
combined$ = "together.txt"
call mergeFiles fileOne$, fileTwo$, combined$
end
sub mergeFiles firstFile$, secondFile$, merged$
open merged$ for output as #merged
open firstFile$ for input as #first
print #merged, input$(#first, lof(#first));
close #first
open secondFile$ for input as #second
print #merged, input$(#second, lof(#second));
close #second
close #merged
end sub
However, you should be careful with your usage of the terms COPY and MERGE.
COPY can be a simple file copy or it can be a concatenation of one or more files, which is what you are doing above.
On the other hand, a MERGE implies merging individual records of each file by some key, which is not what you are doing in your sub mergeFiles.
A word of warning: Copying or concatenating files can be dangerous when you do this from within a program which may interpret end-of-record characters, end-of-file characters, and some special characters differently than MSDOS. The recommended way is to SHELL to the required copy command. Believe me, I found this out the hard way.
*****