scrolling a file up & down 
Author Message
 scrolling a file up & down

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.

Any help would be appreciated.
cheers,
{*filter*}
---


Dept of Anaesthesia, City Hospital, Nottingham, UK
---------------------------------------------------



Wed, 24 Feb 1999 03:00:00 GMT  
 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



Wed, 24 Feb 1999 03:00:00 GMT  
 scrolling a file up & down

Quote:


>Subject: scrolling a file up & down
>Date: 7 Sep 1996 09:50:14 GMT
>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.

There's a not bad  text viewer which does this and a lot more in
one of the ABC packets.  

The basic principle is to;

1.  create an array which contains pointers to the
start of each line in your text file, something like:

Maxline& = 1000  'However many lines you want as maximum
Dim Startposition&(Maxline&)

OPEN "MYFILE.TXT"  FOR INPUT AS #1
Do Until Eof(1) Or Numlines& >Maxline&
  Line Input #1, Text$
  Numlines& = Numlines& + 1
  Startposition&(numlines&) = seek(1)  
Loop      

2. Create a procedure to display any 24 lines
something like:

DIM Strg as STRING * 80

Procedure Displayit(Currentstartline&, CurrentColumn)
  Seek #1, Seeks&(Currentstartline&)
  For I = 1 To 24
    If Not Eof(1) Then
          Line Input #1, Text$
          linelen=len(text$)
       Else
       Text$ = ""
    end if
    Strg = Mid$(Text$, CurrentColumn)
    Locate I, 1, 0: Print Strg;
 Next I
 Seek #1, Seeks&(Currentstartline& )
End Procedure

3.  Create a main loop which reads the keyboard and
modifies Currentstartline& and Currentcolumn depending
on whether an arrow key, page up, page, down, home, end etc
have been pressed. I will leave that part up to you.

--
Disclaimer?? The opinions of the writer ARE the opinions of Lexacorp!!
----------------------------------------------------------------------
LEXACORP Pty Ltd, Brisbane, Qld Australia
Dataflex/MSAccess/Basic System Development



Thu, 25 Feb 1999 03:00:00 GMT  
 scrolling a file up & down

: >Subject: scrolling a file up & down

: >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.

: There's a not bad  text viewer which does this and a lot more in
: one of the ABC packets.  

There must be a couple of them in ABC, because mine uses a temporary file
instead of an array <G>

: 1.  create an array which contains pointers to the
: start of each line in your text file, something like:

: Maxline& = 1000  'However many lines you want as maximum
: Dim Startposition&(Maxline&)

Other than that, the two look pretty similar. The nice thing about not
using an array is that you needn't worry that you might someday want to
exceed it's size.

--
**********************************************************************

-or- http://www.infinet.com/~dgjess                      WaverlyStreet                          



Sat, 27 Feb 1999 03:00:00 GMT  
 scrolling a file up & down

Quote:

> 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.

> Any help would be appreciated.
> cheers,
>{*filter*}

Dick... See if you can find a copy of the program MONEY.BAS.  It
came with the original MSDOS ver 5.0 disks as a sample QBASIC program.  
It has a peek/poke routine to do scroll up & down.  I remember seeing the
doggone thing, but never stopped to figure out how it works...  I don't
have access to an upload here, but you should be able to find it on
Cserve...

--Lee



Sat, 27 Feb 1999 03:00:00 GMT  
 scrolling a file up & down


Quote:

>Subject: Re: scrolling a file up & down
>Date: 10 Sep 1996 13:22:46 -0400

>: >Subject: scrolling a file up & down
>: >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.
>: There's a not bad  text viewer which does this and a lot more in
>: one of the ABC packets.  
>There must be a couple of them in ABC, because mine uses a temporary file
>instead of an array <G>
>: 1.  create an array which contains pointers to the
>: start of each line in your text file, something like:
>: Maxline& = 1000  'However many lines you want as maximum
>: Dim Startposition&(Maxline&)
>Other than that, the two look pretty similar. The nice thing about not
>using an array is that you needn't worry that you might someday want to
>exceed it's size.

The advantage of using an array is speed of loading the file initially, Saving
to a text file slows it down drastically.

As far as size is concerned, I actually set up a two dimensional array in
powerbasic:

DIM Seeks&(0 to 5,0 To 16383)
and Seeks&(LineNum& \ 16382, Linenum& Mod 16382)

This gives me 98,920 lines,
 which tends to run out of storage around 7 - 8 MBytes.

If the file _is_ too big, it just warns you that it can't handle the whole
file and then lets you work in the first 98,920 lines.  (Not that you
want to read text files bigger than that very often <G>)

--
Disclaimer?? The opinions of the writer ARE the opinions of Lexacorp!!
----------------------------------------------------------------------
LEXACORP Pty Ltd, Brisbane, Qld Australia
Dataflex/MSAccess/Basic System Development



Sun, 28 Feb 1999 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. VBA ups & downs

2. vba ups & downs

3. Scroll Bars - detect mouse up & down

4. Textbox scroll - want to automatically scroll down when text is input through event

5. downloading file without pop-ups

6. find the first line after scroll down

7. Problem with scrolling down

8. Boxes move when scrolling down

9. Can't get richtextbox to scroll down to last line after update

10. Scrolling down a Container Control

11. automatically scrolling a listbox down to the first selected item

12. scroll up/down the contents of an OLE object

 

 
Powered by phpBB® Forum Software