How to Scroll Up in Text Screen with BLOAD/BSAVE in Basic (81082)



The information in this article applies to:

  • Microsoft QuickBASIC 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBASIC 4.5
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b
  • Microsoft Basic Professional Development System for MS-DOS 7.0
  • Microsoft Basic Professional Development System for MS-DOS 7.1

This article was previously published under Q81082

SUMMARY

BLOAD and BSAVE statements can be used to scroll text on a text mode (SCREEN 0) screen to avoid having to store the text information in an array and PRINT the entire screen. The drawback to this approach is that you need to create files on the drive for each screen you need to scroll. The code example below shows the screen scrolling up and down using BLOAD and BSAVE.

This information applies to Microsoft QuickBasic versions 1.0, 1.01, 1.02, 2.0, 2.01, 3.0, 4.0, 4.0b, and 4.5 for MS-DOS; Microsoft Basic Compiler versions 6.0 and 6.0b for MS-DOS; and Microsoft Basic Professional Development System (PDS) versions 7.0 and 7.1 for MS-DOS.

MORE INFORMATION

If you have only a few lines to scroll, this method is fairly efficient. However, the overhead of all the files needed to store the screen information may be unacceptable for larger amounts of data. The speed of the scrolling is increased by doing the BSAVEing and BLOADing directly to video memory as noted in the comments below in the example.

Code Example

'  MAIN.BAS: The following main program scrolls the screen
'  up and down.
'
n% = 15
ni% = 7

' PRINT statements scroll the screen down and BLOAD
' statements scroll it back up. The DEF SEG to &HB800 is the
' beginning of text video memory for CGA, EGA, and  VGA
' adapters. By putting 4000 bytes out to the file,the entire
' page is stored.

FOR i% = 1 TO ni%
        PRINT "Willie, Willie : "; i%
        FOR j% = 1 TO n%
                PRINT j%
                DEF SEG = &HB800
                BSAVE "pearljam" + MID$(STR$(j%), 2), 0, 4000
                DEF SEG
        NEXT j%
        FOR j% = n% TO 1 STEP -1
                DEF SEG = &HB800
                BLOAD "pearljam" + MID$(STR$(j%), 2), 0
                DEF SEG
        NEXT j%
NEXT i%
				

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB81082