Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.acorn.programmer > #1561 > unrolled thread
| Started by | Roger Darlington <rogerarm@freeuk.com> |
|---|---|
| First post | 2012-04-01 13:42 +0100 |
| Last post | 2012-04-02 09:28 +0100 |
| Articles | 6 — 3 participants |
Back to article view | Back to comp.sys.acorn.programmer
Merging three files together? Roger Darlington <rogerarm@freeuk.com> - 2012-04-01 13:42 +0100
Re: Merging three files together? Steve Drain <steve@kappa.me.uk> - 2012-04-01 17:48 +0100
Re: Merging three files together? Roger Darlington <rogerarm@freeuk.com> - 2012-04-02 09:33 +0100
Re: Merging three files together? Steve Drain <steve@kappa.me.uk> - 2012-04-02 11:56 +0100
Re: Merging three files together? Martin Bazley <martin.bazley@blueyonder.co.uk> - 2012-04-01 21:53 +0100
Re: Merging three files together? Roger Darlington <rogerarm@freeuk.com> - 2012-04-02 09:28 +0100
| From | Roger Darlington <rogerarm@freeuk.com> |
|---|---|
| Date | 2012-04-01 13:42 +0100 |
| Subject | Merging three files together? |
| Message-ID | <f08f977952.rogerarm@rogerarm.freeuk.com> |
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?
[toc] | [next] | [standalone]
| From | Steve Drain <steve@kappa.me.uk> |
|---|---|
| Date | 2012-04-01 17:48 +0100 |
| Message-ID | <RG%dr.29350$4z7.11783@fx08.am4> |
| In reply to | #1561 |
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
[toc] | [prev] | [next] | [standalone]
| From | Roger Darlington <rogerarm@freeuk.com> |
|---|---|
| Date | 2012-04-02 09:33 +0100 |
| Message-ID | <19a7047a52.rogerarm@rogerarm.freeuk.com> |
| In reply to | #1563 |
On 1 Apr 2012, Steve Drain wrote:
> 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
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.
[toc] | [prev] | [next] | [standalone]
| From | Steve Drain <steve@kappa.me.uk> |
|---|---|
| Date | 2012-04-02 11:56 +0100 |
| Message-ID | <HCfer.116693$xD4.69075@fx06.am4> |
| In reply to | #1568 |
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
[toc] | [prev] | [next] | [standalone]
| From | Martin Bazley <martin.bazley@blueyonder.co.uk> |
|---|---|
| Date | 2012-04-01 21:53 +0100 |
| Message-ID | <d989c47952.martin@blueyonder.co.uk> |
| In reply to | #1561 |
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 ==========================
[toc] | [prev] | [next] | [standalone]
| From | Roger Darlington <rogerarm@freeuk.com> |
|---|---|
| Date | 2012-04-02 09:28 +0100 |
| Message-ID | <8421047a52.rogerarm@rogerarm.freeuk.com> |
| In reply to | #1564 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.sys.acorn.programmer
csiph-web