Pascal Example in Programmer's Guide Won't Compile

Last reviewed: September 16, 1996
Article ID: Q68881
The information in this article applies to:
  • Microsoft Mouse Driver for MS-DOS, versions 6.x, 7.x, 8.x, and 9.0

SUMMARY

The "Making Calls from Borland Turbo Pascal Programs" sample in Appendix E of the "Microsoft Mouse Programmer's Reference" does not compile with Turbo Pascal versions 5.0 and 6.0.

MORE INFORMATION

The CpuReg data structure needs to be defined as "Registers" variables. The semicolons need to be removed from the END lines that immediately precede ELSE. Finally, finding the segment and offset of the pointer of the address of the user array or subroutine (functions 9,12,20,22,23,and 24) needs to be done outside of this procedure. Passing the first element of the array or the start point of the subroutine into the procedure, then calling the "ofs" and "seg" functions in the procedure doesn't seem to work. This is due to how the variables get dereferenced when passed into a procedure.

The following example compiles in both Turbo Pascal version 6.0 and Quick Pascal version 1.00:

Procedure Mouse (Var m1, m2, m3, m4, m5 : integer );

Var

   CpuReg: Registers;

begin {mouse}

   if m1 >= 0 then
      begin
     CpuReg.AX := m1;        { Load Parameters       }
     CpuReg.BX := m2;        { into appropriate      }
     CpuReg.CX := m3;        { registers             }

     if (m1 = 9) or (m1 = 12) or (m1 = 20)
        or (m1 = 22) or (m1 = 23) or (m1 = 24) then
        begin
          CpuReg.DX  :=  m4;    {m4 = offset,         }
          CpuReg.ES  :=  m5;    { and m5 = segment    }
        end                       { of the user array }
                         { or subroutine     }

      else
      if  m1 = 16  then
       begin
         CpuReg.CX  := m2;           {Left  x coordinate }
         CpuReg.DX  := m3;           {Upper y coordinate }
         CpuReg.SI  := m4;           {Right x coordinate }
         CpuReg.DI  := m5;           {Lower y coordinate }
       end
     else
         CpuReg.DX  := m4;

     Intr($33, CpuReg);              {Call mouse driver  }
                            { at Interrupt 33H  }

     m1 := CpuReg.AX;                {Return values back }
     m2 := CpuReg.BX;                { to parameters     }
     m3 := CpuReg.CX;
     m4 := CpuReg.DX;

     if (m1 = 20) then               {special returns    }
        m2 := CpuReg.ES              { from subroutines  }
   end;
end; {mouse}

The Borland product included here is manufactured by a vendor independent of Microsoft; we make no warranty, implied or otherwise, regarding this product's performance or reliability.


KBCategory: kbhw kb3rdparty kbdocerr
KBSubcategory:
Additional reference words: 3rdparty Programming docerr


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 16, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.