TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: ALL
from: BRIAN MCLAUGHLIN
date: 1996-01-07 13:25:00
subject: Saving Screen Colors

For PowerBASIC 3.x programmers, here is a small, but useful piece of
code.  Many user's set their screen colors for DOS to something
other than plain B&W. However, many programs forget to save the
user's screen colors on entry and restore them on exit.  This code
will help you to do so.
To discover your user's current colors, call this code before you
make ANY alteration to the screen.  Store the values for Back% and
Fore%, and then, as your program exits, restore the user's screen
colors like this:
  COLOR Fore%, Back%
  CLS
  END
The CLS will set all the color attributes back to their original
state.  However, if you omit the CLS, the COLOR statement will have
no effect.
'==============================================
 SUB SaveCurrentScreenColors (Fore%, Back%)
'==============================================
'  Written by Brian McLaughlin. Released to public domain 1/07/96.
'  This procedure will return the background and foreground colors
'  at the current cursor position on the screen. For PowerBASIC 3.x
  CursorRow% = CSRLIN                       'get the cursor position
  CursorCol% = POS
  Fore% = SCREEN(CursorRow%, CursorCol%, 1) 'get it's attribute byte
  Back% = Fore%                             'make a copy
  Fore% = Fore% AND 15                      'fore = first 4 bits
  SHIFT RIGHT Back%, 4                      'back = second four bits
END SUB
--- WILDMAIL!/WC v4.12 
---------------
* Origin: Com-Dat BBS - Hillsboro, OR. HST DS (1:105/314.0)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.