Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!uwm.edu!psuvax1!rutgers!cmcl2!adm!news From: TOMJ@csdserver3.csd.scarolina.edu (Thomas E. Jenkins, Jr.) Newsgroups: comp.lang.pascal Subject: Re: Pascal - ATTRIB READ Message-ID: <26873@adm.brl.mil> Date: 13 May 91 20:03:21 GMT Sender: news@adm.brl.mil Lines: 88 >Got a question for you. I've got a small routine that reads the >character from a text screen in 25/43/50 line mode. But it only reads >the character, and not the attributes associated with the character. >Does anyone have a small routine that they'd like to share which can read >the character AND attribute (foreground/background, blinking, hilighted)? > >The program I'm working on is written in Borlands Turbo Pascal Version >5.5... Here's two quick functions from looking in a BIOS reference ( you really need one - they can be life savers ;-) : FUNCTION GetActivePage : BYTE ; VAR regs : Registers ; BEGIN { GetActivePage } WITH regs DO BEGIN ah := $0F ; Intr ( $10 , regs ) ; GetActivePage := bh ; END ; { WITH regs } END ; { GetActivePage } FUNCTION GetChar ( x : BYTE ; y : BYTE ; page : BYTE ) : WORD ; VAR regs : REGISTERS ; BEGIN { GetChar } WITH regs DO BEGIN ah := $08 ; IF ( page = 255 ) THEN bh := GetActivePage ELSE bh := page ; Intr ( $10 , regs ) ; GetChars := ax ; { al = char , ah = attr } END ; { WITH regs } END ; { GetChar } Note that GetChar returns a WORD containing both the character and the attribute. To use this information, simply convert the result's low portion into a CHAR and use the Hi portion as a byte : ch := GetChar ; c := CHR ( Lo ( ch ) ) ; attr := Hi ( ch ) ; tom +--------------------------------------------------------------------------+ | Thomas E. Jenkins, Jr. Programmer, University of South Carolina CSD | +--------------------------------------------------------------------------+ | BITNET : C0361@UNIVSCVM.BITNET | CSDNET : tomj/csdserver3 | | INTERNET : TOMJ@csdserver3.csd.scarolina.EDU {PREFERRED} | | : C0361@univscvm.csd.scarolina.EDU | 129.252.43.30 | | FROM Compuserv : INTERNET:TOMJ@csdserver3.csd.scarolina.EDU {PREFERRED} | | : INTERNET:C0361@univscvm.csd.scarolina.EDU | +--------------------------------------------------------------------------+