home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CBM Funet Archive
/
cbm-funet-archive-2003.iso
/
cbm
/
crossplatform
/
converters
/
msdos
/
arklnx.bas
< prev
next >
Wrap
BASIC Source File
|
1993-09-25
|
6KB
|
239 lines
defint a-z
declare sub getinfo (T$, INF$())
declare sub readblock (BUF$)
declare sub lnxreadline (T$, LINE$)
declare sub arkreadline (T$, LINE$)
option base 1
type ENTRYLINE
FILENAME as string * 16
BLOCKS as integer
LASTBLOCK as integer
STRWDS as integer
end type
' STRWDS = +1 STR +2 WDS +4 PIC +128 MUS
cls
print ".ark/lnx (SIDS) VIEWER. iNPUT THE NAME OF A FILE."
input FILENAME$
FILENAME$ = ucase$(FILENAME$)
if right$(FILENAME$, 4) = ".lnx" or right$(FILENAME$, 4) = ".ark" then FILETYPE$ = right$(FILENAME$, 3): FILENAME$ = left$(FILENAME$, len(FILENAME$) - 4)
if FILENAME$ = "" or len(FILENAME$) > 8 or FILETYPE$ = "" then print "iNVALID FILENAME.": end
print : print "(s)HORT OR (l)ONG FORMAT ? ";
do: FORMAT$ = ucase$(inkey$): loop until FORMAT$ = "l" or FORMAT$ = "s"
print FORMAT$
open FILENAME$ + "." + FILETYPE$ for binary access read as 1
open FILENAME$ + "." + left$(FILETYPE$, 1) + FORMAT$ for output as 2
call readblock(T$)
select case FILETYPE$
case "lnx"
ZERO = 0
POST = 0
do
POST = POST + 1
if mid$(T$, POST, 1) = chr$(0) then ZERO = ZERO + 1 else ZERO = 0
if POST = 255 then print "eRROR IN FILE": end
loop until ZERO = 3
do
POST = POST + 1
loop until mid$(T$, POST, 1) <> chr$(0)
T$ = mid$(T$, POST + 1)
call lnxreadline(T$, L$)
NBLOCKS = val(L$)
call lnxreadline(T$, L$)
NFILES = val(L$)
case "ark"
NFILES = asc(T$)
T$ = mid$(T$, 2)
NBLOCKS = int((29 * NFILES + 1) / 254 + .999)
end select
for I = 1 to NBLOCKS - 1
call readblock(BUF$)
T$ = T$ + BUF$
next I
redim ENTRY(NFILES) as ENTRYLINE, INFO$(NFILES, 5), INF$(5)
for I = 1 to NFILES
select case FILETYPE$
case "lnx"
call lnxreadline(T$, L$)
for J = 1 to 16
if mid$(L$, J, 1) = chr$(160) then mid$(L$, J, 1) = chr$(32)
next J
ENTRY(I).FILENAME = L$
call lnxreadline(T$, L$)
ENTRY(I).BLOCKS = val(L$)
call lnxreadline(T$, L$)
call lnxreadline(T$, L$)
ENTRY(I).LASTBLOCK = val(L$)
case "ark"
call arkreadline(T$, L$)
ENTRY(I).LASTBLOCK = asc(mid$(L$, 2, 1))
for J = 3 to 18
if mid$(L$, J, 1) = chr$(160) then mid$(L$, J, 1) = chr$(32)
next J
ENTRY(I).FILENAME = mid$(L$, 3, 16)
ENTRY(I).BLOCKS = asc(mid$(L$, 28, 1))
end select
next I
for I = 1 to NFILES
T$ = ""
for J = 1 to ENTRY(I).BLOCKS
call readblock(BUF$)
T$ = T$ + BUF$
next J
if right$(rtrim$(ENTRY(I).FILENAME), 4) = ".mus" then
locate 6, 1: print using " ###"; NFILES - I
if FORMAT$ = "l" then
MAX = ENTRY(I).BLOCKS * 254 + ENTRY(I).LASTBLOCK - 256
T$ = left$(T$, MAX)
call getinfo(T$, INF$())
for K = 1 to 5: INFO$(I, K) = INF$(K): next K
end if
FI$ = rtrim$(ENTRY(I).FILENAME)
FI$ = left$(FI$, len(FI$) - 3)
for J = 1 to NFILES
if left$(ENTRY(J).FILENAME, len(FI$)) = FI$ then
Z$ = right$(rtrim$(ENTRY(J).FILENAME), 4)
Z = ENTRY(I).STRWDS or 128
if Z$ = ".str" then Z = Z or 1
if Z$ = ".wds" then Z = Z or 2
if Z$ = ".pic" then Z = Z or 4
ENTRY(I).STRWDS = Z
end if
next J
end if
next I
close 1
FIRST = 1
for I = 1 to NFILES
if ENTRY(I).STRWDS <> 0 then
ENTRY(FIRST) = ENTRY(I)
for K = 1 to 5: INFO$(FIRST, K) = INFO$(I, K): next K
FIRST = FIRST + 1
end if
next I
NFILES = FIRST - 1
locate 6, 1: print " "
'SWAP
do
SWAPS = 0
for I = 1 to NFILES - 1
if ENTRY(I).FILENAME > ENTRY(I + 1).FILENAME then
SWAPS = 1
swap ENTRY(I), ENTRY(I + 1)
for K = 1 to 5: swap INFO$(I, K), INFO$(I + 1, K): next K
end if
next I
loop until SWAPS = 0
for I = 1 to NFILES
SW$ = ".mus"
if ENTRY(I).STRWDS and 1 then SW$ = SW$ + ".str" else SW$ = SW$ + " "
if ENTRY(I).STRWDS and 2 then SW$ = SW$ + ".wds" else SW$ = SW$ + " "
if ENTRY(I).STRWDS and 4 then SW$ = SW$ + ".pic" else SW$ = SW$ + " "
FI$ = rtrim$(ENTRY(I).FILENAME)
FI$ = left$(FI$, len(FI$) - 4)
select case FORMAT$
case "l"
print #2, using " ### \ \ & &"; ENTRY(I).BLOCKS; FI$; SW$; INFO$(I, 1)
for K = 2 to 5: print #2, space$(40); INFO$(I, K): next K
print #2,
case "s"
print #2, using " ### \ \ &"; ENTRY(I).BLOCKS; FI$; SW$
end select
next I
close 2
sub arkreadline (T$, LINE$)
POST = 29
LINE$ = left$(T$, POST - 1)
T$ = mid$(T$, POST + 1)
end sub
sub getinfo (T$, INF$())
MAX = len(T$)
for K = 1 to 5: INF$(K) = "": next K
FINALPOST = 9
FINALPOST = FINALPOST + asc(mid$(T$, 4, 1) + chr$(0)) * 256 + asc(mid$(T$, 3, 1) + chr$(0))
FINALPOST = FINALPOST + asc(mid$(T$, 6, 1) + chr$(0)) * 256 + asc(mid$(T$, 5, 1) + chr$(0))
FINALPOST = FINALPOST + asc(mid$(T$, 8, 1) + chr$(0)) * 256 + asc(mid$(T$, 7, 1) + chr$(0))
if mid$(T$, FINALPOST - 1, 1) = "o" then
T$ = mid$(T$, FINALPOST)
else
T$ = mid$(T$, 9)
POST = 0
for I = 1 to 3
POST = instr(POST + 1, T$, "o")
if POST = 0 then exit for
next I
if POST = 0 then exit sub
T$ = mid$(T$, POST + 1)
end if
C64$ = " !#$%&'()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[\]^_{$60}ABCDEFGHIJKLMNOPQRSTUVWXYZ{$7b}{$7c}{$7d}{$7e}{$7f} {CBM-K}{CBM-I}{CBM-T}{CBM-@}{CBM-G}{CBM-+}{CBM-M}{CBM-POUND}{SHIFT-POUND}{CBM-N}{CBM-Q}{CBM-D}{CBM-Z}{CBM-S}{CBM-P}{CBM-A}{CBM-E}{CBM-R}{CBM-W}{CBM-H}{CBM-J}{CBM-L}{CBM-Y}{CBM-U}{CBM-O}{SHIFT-@}{CBM-F}{CBM-C}{CBM-X}{CBM-V}{CBM-B}{SHIFT-*}ABCDEFGHIJKLMNOPQRSTUVWXYZ{SHIFT-+}{CBM--}{SHIFT--}{$de}{CBM-*} {$e1}{$e2}{$e3}{$e4}{$e5}{$e6}{$e7}{$e8}{$e9}{$ea}{$eb}{$ec}{$ed}{$ee}{$ef}{$f0}{$f1}{$f2}{$f3}{$f4}{$f5}{$f6}{$f7}{$f8}{$f9}{$fa}{$fb}{$fc}{$fd}{$fe}~"
IBM$ = " !#$%&'()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[]^<D#{$7c}----{$7c}{$7c}\\/\\//\#_#{$7c}/xo#{$7c}#+{$7c}{$7c}&\ {$7c}#--{$7c}#{$7c}#/{$7c}{$7c}/\\-/--{$7c}{$7c}{$7c}{$7c}---/\\//#-#{$7c}----{$7c}{$7c}\\/\\//\#_#{$7c}/xo#{$7c}#+{$7c}{$7c}&\ {$7c}#--{$7c}#{$7c}#/{$7c}{$7c}/\\-/--{$7c}{$7c}{$7c}{$7c}---/\\//#"
LIN = 1
for I = 1 to len(T$)
C$ = ""
X = asc(mid$(T$, I, 1) + chr$(0))
Y = instr(C64$, chr$(X))
if Y <> 0 then C$ = mid$(IBM$, Y, 1)
if X = 34 then C$ = chr$(34)
if X = 13 then C$ = "": LIN = LIN + 1: if LIN = 6 then exit for
if X = 0 then exit for
INF$(LIN) = INF$(LIN) + C$
next I
end sub
sub lnxreadline (T$, LINE$)
POST = 0
do
POST = POST + 1
loop until mid$(T$, POST, 1) = chr$(13)
LINE$ = left$(T$, POST - 1)
T$ = mid$(T$, POST + 1)
end sub
sub readblock (BUF$)
BUF$ = space$(254)
get #1, , BUF$
end sub