[comp.lang.pascal] Pascal - ATTRIB READ

mbhimji@nro.cs.athabascau.ca (Mohamed Bhimji) (05/13/91)

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...
  
Thanks in advance!
  
Mohamed


Mohamed Bhimji              ersys!mbhimji@nro.cs.athabascau.ca
Edmonton Remote Systems:  Serving Northern Alberta since 1982

TOMJ@csdserver3.csd.scarolina.edu (Thomas E. Jenkins, Jr.) (05/14/91)

>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              |
+--------------------------------------------------------------------------+

ts@uwasa.fi (Timo Salmi) (05/14/91)

In article <Xkuu21w164w@ersys.uucp> ersys!mbhimji@nro.cs.athabascau.ca (Mohamed Bhimji) writes:
>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...

Is I recall correctly there is something in that vein in tsunta.tpu
in tspa2355.arc.  (Too much material to recall averything even
myself).  Or take a look at almost any of the text-book references
in the Turbo Pascal section of my Frequently Asked Questions
collection.  On the other hand I trust that someone will post the
code. 

...................................................................
Prof. Timo Salmi
Moderating at garbo.uwasa.fi anonymous ftp archives 128.214.12.37
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun