<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Sat, 25 Nov 2006 15:10:41 +0000
From   : thomasharte@... (Thomas Harte)
Subject: Standard file extension for BASIC 2 style code?

Hi,

sorry - I probably explained very poorly.?That code seems to be for opening 
a binary format file and trying to deduce what is probably in it from the 
last few bytes. My emulator already has a piece of code for determining 
if a binary files "looks like" a BASIC file but it starts at the beginning 
and sees if there is apparently an unbroken chain of BASIC style lines. 
It's only used by the bit of my emulator that tries to deduce the correct
command for loading a tape, which is itself just a minor extra feature to
save a little time and/or help those whose memories are otherwise not great.

What the small bit of code I just added to the emulator does is grab a BASIC 
program from memory (so it's already been loaded by the emulated machine 
or created by the user) and save it out to disk (as in the disk attached 
to the PC or Mac running the emulator) as plain ASCII so that you can manipulate 
it in Notepad or TextEdit or whatever. Alternatively you can take a plain 
ASCII file from your disk and have the emulator tokenise it & put it into 
RAM so that you can run it in BASIC or otherwise manipulate it, etc. It's 
all stuff that isn't technically emulation but makes the emulator slightly 
more useful and/or easier to use. I also think it may be a nice feature to
expand upon in the future, maybe add a mode where the emulator is really
just used as an elaborate BASIC interpreter from a separate Mac/PC-native
text editor window, etc.

I know there have been other PC-native implementations of BBC BASIC, so 
I was just curious about whether there is any standard file extension in
the PC/Mac world for "BBC BASIC code saved as ASCII", like .bas or .bbc or
anything like that. At the minute I'm just exporting to files that end with .txt.

-Thomas

> Jonathan Graham Harston wrote:
> 
> > The following bit of code will examine the last four bytes of an
> > open file and determine what format it is:
> >  
> >     PTR#in%=EXT#in%-4:FOR A%=0 TO 3:buffer%?A%=BGET#in%:NEXT
> >     type%=0                                       :REM unknown
> >     IFbuffer%?3=&0D                      :type%=7 :REM text cr
> >     IFbuffer%?3=&0A                      :type%=6 :REM text lf
> >     IF(!buffer% AND &FFFF0000)=&0D0A0000 :type%=5 :REM text lfcr
> >     IF(!buffer% AND &FFFF0000)=&0A0D0000 :type%=4 :REM text crlf
> >     IF(!buffer% AND &FFFF0000)=&FF0D0000 :type%=2 :REM 6502 format
> >     IF!buffer%=&FFFF000D                 :type%=1 :REM 80/86 format
> >  
> > This assumes that the BASIC program has not got any extra bytes
> > appended after the final terminator.
> 
> Which is exactly what a lot of Acornsoft BASIC programs do have, so this 
> isn't a good test.
> 
> -- 
> Pete                                              Peter Turnbull
>                                           Network Manager
>                                           University of York

Lycos email has 300 Megabytes of free storage... Get it now@...

<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>