Re: Virtual Screen S 1/

 BBS: Inland Empire Archive
Date: 03-15-92 (13:23)             Number: 126
From: MICHAEL MALLEY               Refer#: NONE
  To: ROBBIE CHURCH                 Recvd: NO  
Subj: Re: Virtual Screen S  1/       Conf: (2) Quik_Bas
RC>Did I miss a virtual screen routine?  I've been waiting for this one for
RC>weeks!  Could you please repost?  Please?  Please?   (No pressure)

Hmmmmmm...  Not sure if Dave Cleary is going to include it in the QBNews
or not.  Well O.K.

 ----------------------[ VIRTUAL.BAS ]-----------------------

DECLARE SUB Scroll (Row1%, Col1%, Row2%, Col2%, Lines%, attr%)
DEFINT A-Z

'-- We need the following type and declaration for accessing the BIOS scroll
'   screen function.  You'll have to load QB.QLB/QBX.QLB for this.

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

DECLARE SUB Interrupt (intnum AS INTEGER, Inreg AS RegType, outreg AS_
 RegType)


'-- You need to have an array containing the text for the screen
'   If we diminsion it as string, that will allow for variable
'   lengths without wasting memory.  We are going to use ASCII
'   codes of 32 to 255 as our virtual text.
DIM Text(1 TO 224) AS STRING

TopLine = 1         'Pointer shows what element is the top line
NumberOfLines = 23  'Number of rows to show at one time
CurrentCol = 1      'What "column" to start at in the element

COLOR 7, 0
CLS
LOCATE , , 0   'Turn off the cursor

'Let's make some stuff to show on the screen
Text(1) = SPACE$(224)
FOR Counter = 32 TO 255
  MID$(Text(1), Counter - 31) = CHR$(Counter)
NEXT Counter

Offset = 2
FOR Counter = 2 TO 224
  Text(Counter) = SPACE$(224)

  MID$(Text(Counter), 1) = MID$(Text(1), Offset)
  NextPosition = 225 - (Offset - 1)
  MID$(Text(Counter), NextPosition) = LEFT$(Text(1), (Offset - 1))
  Offset = Offset + 1
NEXT Counter

GOSUB ShowScreen

DO
  WHILE LEN(INKEY$): WEND 'Clear keyboard buffer
  DO
    KeyStroke$ = INKEY$
  LOOP UNTIL LEN(KeyStroke$)

  IF LEN(KeyStroke$) = 2 THEN
    SELECT CASE ASC(RIGHT$(KeyStroke$, 1))
      CASE 72 'Up
        TopLine = TopLine - 1
        IF TopLine THEN
          Scroll 2, 1, 24, 80, -1, 7
          LOCATE 2, 1
          PRINT MID$(Text(TopLine), CurrentCol, 80);
        ELSE
          TopLine = 1
        END IF

      CASE 80 'Down
        TopLine = TopLine + 1
        IF TopLine < 203 THEN
          Scroll 2, 1, 24, 80, 1, 7
          LOCATE 24, 1
          PRINT MID$(Text(TopLine + 22), CurrentCol, 80);
        ELSE
          TopLine = 202
        END IF

      CASE 75 'Left
        CurrentCol = CurrentCol - 1
        IF CurrentCol THEN
            GOSUB ShowScreen
        ELSE
            CurrentCol = 1
        END IF

      CASE 77 'Right
        CurrentCol = CurrentCol + 1
        IF CurrentCol < 146 THEN
            GOSUB ShowScreen
        ELSE
            CurrentCol = 145
        END IF

      CASE 71 'Home
        CurrentCol = CurrentCol - 1
        IF CurrentCol THEN
          TopLine = TopLine - 1
          IF TopLine THEN
            GOSUB ShowScreen
          ELSE
            TopLine = 1
          END IF
        ELSE
          CurrentCol = 1
        END IF

      CASE 79 'End
        CurrentCol = CurrentCol - 1
        IF CurrentCol THEN
          TopLine = TopLine + 1
          IF TopLine < 203 THEN
            GOSUB ShowScreen
          ELSE
            TopLine = 202
          END IF
        ELSE
          CurrentCol = 1
        END IF

      CASE 73 'Page Up
        CurrentCol = CurrentCol + 1
        IF CurrentCol < 146 THEN
          TopLine = TopLine - 1
          IF TopLine THEN
            GOSUB ShowScreen
          ELSE
            TopLine = 1
          END IF
        ELSE
          CurrentCol = 145
        END IF
      CASE 81 'Page Down
        CurrentCol = CurrentCol + 1
>>> Continued to next message

 * SLMR 2.1a * It's not crippled, it's functionally challenged!
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