On 01/04/2012 13:42, Roger Darlington wrote:
> I cant help thinking that there must be a simpler (and quicker) way of
> merging 3 files together (within a program) than printing them to
> screen and *spooling the result, but can find no 'merge' nor
> 'concatenate' command in RO nor BASIC.
>
> SPOOL "<!Genus_Fam$Dir>.GeneraToFamilyInfo/htm"
> PRINT "<!Genus_Fam$Dir>.Header"
> PRINT "<!Genus_Fam$Dir>.Middle"
> PRINT "<!Genus_Fam$Dir>.Footer"
> *Spool
>
> Is there a simpler and quicker way (within BASIC).
I am sure there are many ways to do this, but I suspect that they all
need to load bytes from the source files and save them to the
destination file. Here is one:
new%=OPENOUT"GeneraToFamilyInfo/htm"
PROCappend("Header",new%)
PROCappend("Middle",new%)
PROCappend("Footer",new%)
CLOSE#new%
END
DEF PROCappend(add$,new%)
LOCAL add%,not%
add%=OPENINadd$
REPEAT
SYS"OS_GBPB",4,add%,END,256 TO ,,,not%
SYS"OS_GBPB",2,new%,END,256-not%
UNTIL not%
CLOSE#add%
ENDPROC
Note the use of END as a temporary buffer here and be careful that you
do not change the routine to create any heap objects.
Steve