Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Merging three files together?

6 views
Skip to first unread message

Roger Darlington

unread,
Apr 1, 2012, 8:42:21 AM4/1/12
to

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).

--

Cheers
Roger
Lonely pen tops. Where are their pen pals?

Steve Drain

unread,
Apr 1, 2012, 12:48:44 PM4/1/12
to
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

Martin Bazley

unread,
Apr 1, 2012, 4:53:37 PM4/1/12
to
The following bytes were arranged on 1 Apr 2012 by Roger Darlington :

> SPOOL "<!Genus_Fam$Dir>.GeneraToFamilyInfo/htm"
> PRINT "<!Genus_Fam$Dir>.Header"
> PRINT "<!Genus_Fam$Dir>.Middle"
> PRINT "<!Genus_Fam$Dir>.Footer"
> *Spool

While it won't solve your fundamental problem of this being a filthy
bodge which really should have a better solution, this will at least be
slightly quicker:

(Note: The following should be three single lines!)

*Copy <!Genus_Fam$Dir>.Header <!Genus_Fam$Dir>.GeneraToFamilyInfo/htm ~C~VF
*Print <!Genus_Fam$Dir>.Middle { >> <!Genus_Fam$Dir>.GeneraToFamilyInfo/htm }
*Print <!Genus_Fam$Dir>.Footer { >> <!Genus_Fam$Dir>.GeneraToFamilyInfo/htm }

> Is there a simpler and quicker way (within BASIC).

What are you on about? There's no such thing as a SPOOL command in
BASIC, and the PRINT keyword certainly doesn't behave as you imply
above!

--
__<^>__ "Start off every day with a smile and get it over with."
/ _ _ \ - W.C. Fields
( ( |_| ) )
\_> <_/ ======================= Martin Bazley ==========================

Roger Darlington

unread,
Apr 2, 2012, 4:33:55 AM4/2/12
to
OK, thanks Steve.

Would a MERGE command or CONCATENATE command be a suitable candidate
for inclusion in your BASALT BASIC extension?

I seem to remember that even HP BASIC has a MERGE command, which will
merge files together.

> 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


--

Cheers
Roger
Off-road doesn't mean on-pavement.

Roger Darlington

unread,
Apr 2, 2012, 4:28:13 AM4/2/12
to
On 1 Apr 2012, Martin Bazley wrote:
> The following bytes were arranged on 1 Apr 2012 by Roger Darlington :

>> SPOOL "<!Genus_Fam$Dir>.GeneraToFamilyInfo/htm"
>> PRINT "<!Genus_Fam$Dir>.Header"
>> PRINT "<!Genus_Fam$Dir>.Middle"
>> PRINT "<!Genus_Fam$Dir>.Footer"
>> *Spool

> While it won't solve your fundamental problem of this being a filthy
> bodge which really should have a better solution, this will at least be
> slightly quicker:

> (Note: The following should be three single lines!)

> *Copy <!Genus_Fam$Dir>.Header <!Genus_Fam$Dir>.GeneraToFamilyInfo/htm ~C~VF
> *Print <!Genus_Fam$Dir>.Middle { >> <!Genus_Fam$Dir>.GeneraToFamilyInfo/htm }
> *Print <!Genus_Fam$Dir>.Footer { >> <!Genus_Fam$Dir>.GeneraToFamilyInfo/htm }

OK, thanks Martin

>> Is there a simpler and quicker way (within BASIC).

> What are you on about? There's no such thing as a SPOOL command in
> BASIC, and the PRINT keyword certainly doesn't behave as you imply
> above!

It seems that all the OSCLI commands dissappeared when I copied the
extract from Zaps BASIC editor into MessPros e-mail editor :-((

I just deleted all those curious spurious characters not realising
that they were the remnants of the OSCLI commands...




--

Cheers
Roger
What a scandal: The vandals stole the handles off all the candles

Steve Drain

unread,
Apr 2, 2012, 6:56:37 AM4/2/12
to
On 02/04/2012 09:33, Roger Darlington wrote:
> OK, thanks Steve.
>
> Would a MERGE command or CONCATENATE command be a suitable candidate
> for inclusion in your BASALT BASIC extension?
>
> I seem to remember that even HP BASIC has a MERGE command, which will
> merge files together.

I do not think BASIC should provide keywords that are exclusively for
the filer. I imagine that HP BASIC was doing the job of our *commands.

If you want a neater filer method, you could take Martin's suggestion
and alias it. Run an Obey file:

Set Alias$Merge "Print %%0 { >> %%1 }"

Then you can use this, in an OSCLI construct if you want:

*Create Newfile
*Merge Header Newfile
*Merge Middle Newfile
*Merge Footer Newfile

As an aside, I have written an extended BGET/BPUT pair that work with
multiple bytes, so they hide this:

SYS"OS_GBPB",4,add%,END,256 TO ,,,not%
SYS"OS_GBPB",2,new%,END,256-not%

in this:

BGET#add%,END,256 TO not%
BPUT#new%,END,256-not%

Steve
0 new messages