[comp.lang.pascal] register set

Alex.Brown@p0.f7.n391.z8.fidonet.org (Alex Brown) (07/01/90)

	I got the following code from the Turbo Pascal v5.5 help file 
and I still get an error code (type mismatch) when I try to compile

Can anyone help me? I've tried everything I can think of!


uses dos;
procedure cursor_off(stype : char);

  type
    {Registers record used by Intr and MsDos}
    Registers = record
                  case Integer of
                    0: (AX,BX,CX,DX,BP,SI,DI,
                        DS,ES,Flags: Word);
                    1: (AL,AH,BL,BH,CL,CH,DL,
                        DH: Byte);
                end;
var
  regs : registers;

begin
with regs do
  begin
  AH :=$01;
  CH :=20;
  CL :=20;
  end;
intr($10, regs);
end;

begin
cursor_off(c);
end.
--  
-------------------------------------------------------------------------------
N.W. Arkansas' UUCP to FidoNet Connection. If you are interested in connecting
up Contact Kenneth Whelan.   Addresses  postmaster@palace or at 1:391/9(Fido)
-------------------------------------------------------------------------------

kim@spock (Kim Letkeman) (07/02/90)

In article <16.268E1000@palace.fidonet.org>, Alex.Brown@p0.f7.n391.z8.fidonet.org (Alex Brown) writes:
| 	I got the following code from the Turbo Pascal v5.5 help file 
| and I still get an error code (type mismatch) when I try to compile
| 
| Can anyone help me? I've tried everything I can think of!
| 
| uses dos;
| procedure cursor_off(stype : char);
| 
|   type
|     {Registers record used by Intr and MsDos}
|     Registers = record

The dos unit contains that type. The procedure intr was compiled
against the dos unit's version of the record, so although yours is
identical, turbo does not recognize it as the same type or as an
alias.

It should work fine if you cut out your definition of the type and
recompile. 

-- 
Kim Letkeman    mitel!spock!kim@uunet.uu.net

ts@uwasa.fi (Timo Salmi LASK) (07/02/90)

In article <16.268E1000@palace.fidonet.org> Alex.Brown@p0.f7.n391.z8.fidonet.org (Alex Brown) writes:
>	I got the following code from the Turbo Pascal v5.5 help file 
>and I still get an error code (type mismatch) when I try to compile
... deleted ...
>uses dos;
>procedure cursor_off(stype : char);
>  type
>    {Registers record used by Intr and MsDos}
>    Registers = record
>                  case Integer of
>                    0: (AX,BX,CX,DX,BP,SI,DI,
>                        DS,ES,Flags: Word);
>                    1: (AL,AH,BL,BH,CL,CH,DL,
>                        DH: Byte);
>                end;
... deleted ...

I have noticed the same problem myself.  The solution is
straightforward.  Do not define type registers yourself since it is
intrinsic in the Dos unit.  Leave the above type definition out, and
then define, say var regs : registers; in your procedure.  This will
work. 

...................................................................
Prof. Timo Salmi        (Moderating at anon. ftp site 128.214.12.3)
School of Business Studies, University of Vaasa, SF-65101, Finland
Internet: ts@chyde.uwasa.fi Funet: gado::salmi Bitnet: salmi@finfun