
scrolling a file up & down
Quote:
> HELP - I am writing a program, and as part of it I want
> to include a subroutine (I am using QB4.5) to access a file
> and then scroll it UP and DOWN in a window.
> So far I have made a sub which does all this EXCEPT the scrolling
> UP.
> So my question is can anyone help me with a short routine which
> will scroll up as well as down, or perhaps tell me where to
> download such a thing.
> At the moment I just input lines from the file and
> print them to the scren when I press the arrow DOWN key.
> Thats easy, but how does one seamlessly scroll UP, and
> coordinate erasing lines at the top etc.
Here is an example of using the Interrupt routine of QB 4.5 to
call BIOS interrupt 10H (16 decimal) to scroll the display
either up or down. (It's fast too.)
You will have to start QB with the /L option to be able to use the
Interrupt routine.
I didn't write the Scroll sub, it's from the user interface toolbox
that is included with PDS 7 although I did correct the bug that causes
the blank lines to always be black when scrolling down. (hope MS doesn't mind)
By specifying row1,col1 & row2,col2 you can scroll the whole screen or
just some portion of the screen.
NOTE: I Commented out a couple of lines in the Scroll sub that make sure
that the rows & columns to be scrolled are within the screen boundries
before calling the BIOS interrupt. You may want to put them back in.
row1/col1 specify the upper left corner of the area to be scrolled.
row2/col2 specify the lower right corner of the area to be scrolled.
lines = specifies how far to scroll. + values = scroll up, -values = scroll down.
attr = color attribute for blank lines created by the scroll.
DECLARE SUB scroll (row1, col1, row2, col2, lines, attr)
TYPE RegType
AX AS INTEGER
BX AS INTEGER
CX AS INTEGER
DX AS INTEGER
BP AS INTEGER
SI AS INTEGER
DI AS INTEGER
FLAGS AS INTEGER
END TYPE
'This part is just to demo the scrolling.
COLOR 15, 1
CLS
FOR i = 65 TO 87
PRINT STRING$(70, CHR$(i)) ' Just put somd data on screen
NEXT i
DO WHILE INKEY$ = "": LOOP ' wait for a keypress
scroll 1, 1, 20, 60, -4, 1 ' scroll down 4 lines (rows 1-20, columns 1-60 only)
DO WHILE INKEY$ = "": LOOP ' wait for a keypress
END
SUB scroll (row1, col1, row2, col2, lines, attr)
' =================================================================
' Make sure coordinates are in proper order
' =================================================================
IF row1 > row2 THEN
SWAP row1, row2
END IF
IF col1 > col2 THEN
SWAP col1, col2
END IF
' ================================================================
' If coordinates are valid, prepare registers, and call interrupt
' ================================================================
' IF row1 >= MINROW AND row2 <= MAXROW AND col1 >= MINCOL AND col2 <= MAXCOL
DIM regs AS RegType
IF lines < 0 THEN ' Scroll down
regs.AX = 256 * 7 + (-lines)
regs.BX = 256 * (attr MOD 8) * 16 ' there was a bug here but it's fixed now.
regs.CX = 256 * (row1 - 1) + (col1 - 1)
regs.DX = 256 * (row2 - 1) + (col2 - 1)
ELSE ' Scroll up
regs.AX = 256 * 6 + lines
regs.BX = 256 * (attr MOD 8) * 16
regs.CX = 256 * (row1 - 1) + (col1 - 1)
regs.DX = 256 * (row2 - 1) + (col2 - 1)
END IF
CALL INTERRUPT(16, regs, regs)
'END IF
END SUB
Here is a description of the BIOS Interrupt 10h functions called by the Scroll sub.
Function 06h Scroll Page Up
scroll up or initialize a display "window"
entry AH 06h
AL number of lines blanked at bottom of page
00h blank entire window
BH attributes to be used on blank line
CH row (Y) of upper left corner or window
CL column (X) of upper left corner of window
DH row (Y) of lower right corner of window
DL column (X) of lower right corner of window
return none
note 1) Push BP before scrolling, pop after (early IBM PCs didn't
save BP).
2) Affects current video page only.
Function 07h Scroll Page Down
scroll down or clear a display "window"
entry AH 07h
AL number of lines to be blanked at top of page
00h blank entire window
BH attributes to be used on blank line
CH row (Y) of upper left corner or window
CL column (X) of upper left corner of window
DH row (Y) of lower right corner of window
DL column (X) of lower right corner of window
return none
--
Bangor, Pa. USA