home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Boston 2
/
boston-2.iso
/
DOS
/
PROGRAM
/
BASIC
/
POWBASIC
/
LIBRARY5
/
LSTRAN.ZIP
/
LSTRANGE.BAS
< prev
next >
Wrap
BASIC Source File
|
1990-06-08
|
3KB
|
112 lines
$compile EXE
$error all off
$lib all off
$option autodim off
$option cntlbreak off
$float emulate
$stack 2048
$include "PBSTD.INC" ' Standard named constants
$include "FILEUTIL.INC" ' Some standard routines
Title$ = " LstRange.EXE Michael E. Flenniken 6-6-90"
if instr(command$, " ") then
FileName$ = left$(command$, instr(command$, " "))
else
FileName$ = command$
end if
WksHandle% = Open123% (FileName$)
if WksHandle% = %False then
? Title$
?
? " Syntax: LSTRANGE [<path>]<filespec>"
? " where <filespec> is the file name of the spreadsheet to read. If no"
? " extension is specified, LSTRANGE will look for <filespec>.WKS "
? " first, and if unseccessful, will look for <filespec>.WK1"
? " <path> is an optional DOS path specification.
?
? "Unable to open file"
END
end if
call StdOut (Title$, 13)
call StdOut ("", 13)
call StdOut (" List of named ranges for " +ucase$(FileName$) +":", 13)
do
call Read123Rec
if cvi(RecType$$) = %RangeName1 _
or cvi(RecType$$) = %RangeName2 then
Col1% = cvi(mid$(RecData$$, 17, 2))
Row1% = cvi(mid$(RecData$$, 19, 2))
Col2% = cvi(mid$(RecData$$, 21, 2))
Row2% = cvi(mid$(RecData$$, 23, 3))
NameOut$ = using$(" \ \ ", extract$(RecData$$, chr$(0)))
AddrOut$ = left$(CellAddress$ (Col1%, Row1%) +".." _
+CellAddress$ (Col2%, Row2%) +space$(16), 16)
call StdOut (NameOut$, 0)
call StdOut (AddrOut$, 0)
if Column% = 2 then
call StdOut ("", 13)
Column% = 1
else
call StdOut (space$(2), 0)
Column% = 2
end if
end if
loop until eof(1)
close WksHandle%
END
'************************************************************************
%Signature123 = 0
%RangeName1 = 11
%RangeName2 = 71
sub Read123Rec
shared Record123$$, RecType$$, RecLength$$, RecData$$
get$ #1, 4, Record123$$
get$ #1, cvi(RecLength$$), RecData$$
end sub
function CellAddress$ (Col%, Row%)
if Col% > 25 then
Cell$ = chr$(Col% \26 +64)
end if
CellAddress$ = Cell$ +chr$(Col% mod 26 +65) +mid$(str$(Row% +1), 2)
end function
function Open123% (FileToOpen$)
local FileName$, WksHandle%
shared Record123$$, RecType$$, RecLength$$, RecData$$
FileName$ = DefaultExt$ (FileToOpen$, "WKS") ' Validate file name
if not Exists% (FileName$) then
FileName$ = DefaultExt$ (FileToOpen$, "WK1")
if not Exists% (FileName$) then
Open123% = %False
end if
end if
WksHandle% = GetHandle% (FileName$, "Binary")
if WksHandle% < 1 then
Open123% = %False
exit function
end if
map Record123$$ * 259, 2 as RecType$$, 2 as RecLength$$, 255 as RecData$$
call Read123Rec
if left$(Record123$$, 6) = chr$(%Signature123, 0, 2, 0, 4, 4) _
or left$(Record123$$, 6) = chr$(%Signature123, 0, 2, 0, 6, 4) then
Open123% = WksHandle%
else
Open123% = %False
end if
end function