'===========================================================================
' Subject: MELT CHARACTERS OFF SCREEN         Date: 02-06-97 (14:09)       
'  Author: Dave Navarro, Jr.                  Code: PB                     
'  Origin: dave@powerbasic.com              Packet: TEXT.ABC
'===========================================================================
'Melt all the charactors off of the screen.
'by Dave Navarro, Jr.
'requires PowerBASIC 3.0 or later

DEFINT A-Z

Cells = pbvScrnRows * pbvScrnCols - 1
Range = Cells

IF BIT(pbvScrnCard, 1) THEN
  DIM DYNAMIC ScreenMem(0:1999) AT &HB800  'color screen address
ELSE
  DIM DYNAMIC ScreenMem(0:1999) AT &HB000  'mono screen address
END IF

DO
  Cells = Range                 'restore value
  FOR x = 0 TO Range
    cell = ScreenMem(x)         'get char & attribute from screen
    Char = ch AND &HFF          'isolate char
    IF Char = 32 THEN           'is it a space?
      Cell = &H0720             'yes, make sure it's white on black
      DECR Cells                'one less non-space on screen
    ELSEIF Char < 32 THEN       'is it a control char?
      INCR Cell                 'add one to move it closer to a space
    ELSE                        'it's above a space
      DECR Cell                 'so subtract one to move it close to a
space
    END IF
    ScreenMem(x) = Char         'put it back
  NEXT
LOOP WHILE Cells >= 0           'keep looping until their all spaces
