BBS: Inland Empire Archive Date: 09-12-92 (11:26) Number: 254 From: TONY ELLIOTT Refer#: NONE To: WALTON DELL Recvd: NO Subj: CGA or Mono? Conf: (2) Quik_Bas
Walton,
WD> How can I tell if a mono or color moniter is being used,
>WITHOUT using ON ERROR? Right now I just use ON ERROR with
>a WIDTH 40 (can still use NOGRAPH.OBJ), but I'd like to be
>able to stub out error traping!
The bottom line is ... You can't. At least, not 100% accurately. You
can easily determine the type of video -adapter- present, but not the
type of monitor attached. This is what I do, and it works 99% of the
time:
DECLARE FUNCTION IsAColor% ()
IF IsAColor% THEN
PRINT "A color ";
ELSE
PRINT "A b/w ";
END IF
PRINT "monitor is attached"
END
FUNCTION IsAColor% ()
DEF SEG = 0
VidMode% = PEEK(&H449) 'Current video mode
DEF SEG
SELECT CASE VidMode%
CASE 0,2 'Black & White 40/80 Column
Result% = 0
CASE 1,3 'Color 40/80 Column
Result% = -1
CASE 7 'Monochrome (b/w)
Result% = 0
CASE ELSE 'Must be Graphics .. assume B/W
Result% = 0
END SELECT
IsAColor% = Result%
END FUNCTION
Before someone points it out to be, the above code can be reduced
to just a couple of lines. I wrote it like this to make it clear
and easy to understand.
The start-up system video mode is defined by either jumpers/switches on
your motherboard, or a field in the CMOS configuration table. After
the system boot, these video modes can be changed using the DOS "MODE"
utility. For example:
MODE bw40 'Sets video mode 0
MODE bw80 'Mode 1
MODE co40 'Mode 2
MODE co80 'Mode 3
MODE MONO 'Mode 7
Most commercial apps (including Norton, PCTools, etc.) determine if
the adapter/monitor combination can display colors by these modes.
If you want to know precisely what type of adapter is present
(CGA/EGA/VGA/MONO/HERC, etc.), I've got code for that, too ... As does
most commercial and shareware libraries.
Hope this helps!
Tony
___
X 1st 1.01b #1030s X I remember when Saturns were rockets, not cars.
--- Maximus 2.01wb
* Origin: Oakland BBS (1:133/706)

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