BBS: Inland Empire Archive Date: 02-03-93 (09:02) Number: 373 From: LAWRENCE GORDON Refer#: NONE To: DENIS DUBUC Recvd: NO Subj: File viewer Conf: (2) Quik_Bas
> I would like to know how to the Command for viewing a
> text file that is more then 25 line long by having a
> thing like press a key to continue without having the
> file scrolling down to the END.The only thing that
> I've been able to do so far is using the | MORE
> Command, but there must be another way to control the
> text, I checked the 3 Books that I have but I haven't
> find anything. Could someone please help me?
Here's one that works in PowerBASIC. You would only need
to modify a few lines to change it over to QuickBasic.
It has the ability to scroll up or down, but not left or right.
=================================start=========================
rem ** viewer.bas **
defint a-z
%false = 0
%true = NOT %false
uparrow = 18432
downarrow = 20480
pgup = 18688
pgdn = 20736
home = 18176
endkey = 20224
escape = 27
dim a$(1:2000)
filename$ = command$
on error goto fileerror
call fileread (filename$, linecount%, a$())
on error goto 0
cls
lineptr% = 1
do
color 0,3
locate 1,1
print "Line:";left$(str$(lineptr%)+space$(7),8);
print "File: ";left$(filename$+space$(19),19);
print "Quit: ESC";space$(3);
print "Move ";chr$(24);" ";chr$(25);" PGUP PGDN HOME END ";
color 7,1
for i% = 0 to 23
locate i% + 2, 1
print left$(a$(i% + lineptr%)+ space$(80),80);
next i%
select case keycode%
case uparrow
if lineptr% > 1 then
lineptr% = lineptr% - 1
end if
case downarrow
if lineptr% < linecount% then
lineptr% = lineptr% + 1
end if
case pgup
if lineptr% > 1 then
lineptr% = lineptr - 24
if lineptr% < 1 then
lineptr% = 1
end if
end if
case pgdn
if lineptr% < linecount% - 24 then
lineptr% = lineptr% + 24
if lineptr% > linecount% then
lineptr% = linecount%
end if
end if
case home
if lineptr% > 1 then
lineptr% = 1
end if
case endkey
if lineptr% < linecount% - 24 then
lineptr% = linecount% - 24
end if
case escape
quitflag% = %true
case else
updateflag% = %false
end select
loop until quitflag%
color 7,0
end
fileerror:
print
print "Usage: VIEWER filename.ext"
system
resume next
sub fileread (filename$, linecount%, a$()) STATIC
filenumber% = freefile
open filename$ for input as filenumber%
for i% = lbound(a$(1)) to ubound(a$(1))
line input #filenumber%, a$(i%)
linecount% = i%
if eof(filenumber%) then
exit for
end if
next i%
if not eof(filenumber%) then
linecount% = -1
end if
end sub
function keycode% static
do
k$ = inkey$
loop until k$ <> ""
keycode% = cvi(k$ + chr$(0))
end function
==============================end============================
-=> Lawrence <=-
___ Blue Wave/QWK v2.12
--- WM v2.06/92-0545
* Origin: Toast House - (314) 994-0312 - (1:100/560)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET