Re: Scrolling

 BBS: Inland Empire Archive
Date: 03-07-93 (14:37)             Number: 329
From: BOB PERKINS                  Refer#: NONE
  To: TODD TYLER                    Recvd: NO  
Subj: Re: Scrolling                  Conf: (2) Quik_Bas
 TT> I'd like to know how to go about displaying information on
 TT> the screen that is more than one screenful, and be able to
 TT> scroll it up or down.  I can't seem to figure out how this
 TT> is done, other than maybe the info is stored in some kind of buffer?

  Here's a simple way you could go about it.  Should give
you a starting point anyway.

 DIM text(1 TO 300) AS STRING * 80   '300 80-character lines of storage
 DECLARE SUB put2screen (start%, count%)
 OPEN "test.txt" FOR INPUT AS #1
 count% = 0
 CLS
 LOCATE 25, 1: COLOR 0, 7: PRINT SPACE$(80);
 LOCATE 25, 30: PRINT "Obligatory Status Bar";
 COLOR 7, 1
 'read entire file into array keeping track of the top record with count%
 DO WHILE NOT EOF(1)
  count% = count% + 1
  LINE INPUT #1, text(count%)
  IF count% > 299 THEN          'array overflow protection..
    BEEP: PRINT "Couldn't load the whole file..": SLEEP 2: EXIT DO
  END IF
 LOOP
 CLOSE #1
 start% = 1                   'set pointer to first line of file
 put2screen start%, count%    'start out by displaying first page of data
 esc$ = CHR$(27): null$ = CHR$(0)
 DO
  a$ = INKEY$
  IF LEN(a$) THEN
    SELECT CASE a$
      CASE null$ + "H"                     'Up Arrow
        IF start% > 1 THEN
          start% = start% - 1
          put2screen start%, count%
        END IF
      CASE null$ + "P"                     'Down Arrow
        IF start% < count% THEN
          start% = start% + 1
          put2screen start%, count%
        END IF
      CASE null$ + "Q"                     'Page Down
        start% = start% + 24
        IF start% > count% THEN start% = count%
        put2screen start%, count%
      CASE null$ + "I"                     'Page Up
        start% = start% - 24
        IF start% < 1 THEN start% = 1
        put2screen start%, count%
      CASE esc$: EXIT DO
    END SELECT
  END IF
 LOOP
 END

 SUB put2screen (start%, count%)
   SHARED text() AS STRING * 80
   'start is starting record number from 1 to count%
   t% = 1
   CLS 2
   FOR x% = start% TO start% + 23     'use full screen
     IF x% > count% THEN EXIT FOR
     LOCATE t%, 1: PRINT text(x%);
     t% = t% + 1
   NEXT x%
 END SUB

--- Msg V4.5
 * Origin: Reciprocity Failure  (1:124/4115.236)
Outer Court
Echo Basic Postings

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