<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Sat, 25 Nov 2006 11:08:13 +0000
From   : pete@... (Pete Turnbull)
Subject: Standard file extension for BASIC 2 style code?

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
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>