Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Type Mismatch

NinthAngleNinthAngle Posts: 98Member
I am trying to store the number of times a user of a program ive written clicks the 'left' or 'right' mouse button. To see whether or not the user presses a mouse button I am using the following code:

PROGRAM Mouze;
USES Crt;
VAR MouseX, MouseY: Word;
MouseB: Byte;
key: char;


PROCEDURE GetMouse(VAR MouseX, MouseY : Word; VAR MouseB : Byte); Assembler;
ASM
Mov Ax, $0003 { Function 3 = Get Mouse X,Y & Buttons }
Int $33 { Int $33 = Mouse Functions }
Shr Cx, 1 { Divide MouseX by 2 }
Les Di, MouseX { ES:DI = @MouseX }
Mov Es:[Di], Cx { MouseX is returned as 0-639, I want 0-319 }
Les Di, MouseY { ES:DI = @MouseY }
Mov Es:[Di], Dx { MouseY is returned as 0-199 }
Les Di, MouseB { ES:DI = @MouseB }
Mov Es:[Di], Bl { Mouse Buttons }
End;

BEGIN

begin
repeat
GetMouse(MouseX, MouseY, MouseB); { Sets the variables }
GotoXY(1, 1);
writeln(MouseX, MouseY); { Uses the location }
until MouseB > 0; { Checks if the user clicks to end the program }
end;
END.

Now Ive integrated this code into a larger program which is probably too much of a hassle to post here. Part of this program is designed to store anything the user puts into the computer (ie the mouse click) and stores this in a .DAT file. Part of the code I use to store anything in these DAT files requires me to assign "MouseB" to "Answer[runs]" Answer[runs]:=MouseB;

Pascal will not accept this calling it a type mismatch... What do I need to change???

Comments

  • zibadianzibadian Posts: 6,349Member
    : I am trying to store the number of times a user of a program ive written clicks the 'left' or 'right' mouse button. To see whether or not the user presses a mouse button I am using the following code:
    :
    : PROGRAM Mouze;
    : USES Crt;
    : VAR MouseX, MouseY: Word;
    : MouseB: Byte;
    : key: char;
    :
    :
    : PROCEDURE GetMouse(VAR MouseX, MouseY : Word; VAR MouseB : Byte); Assembler;
    : ASM
    : Mov Ax, $0003 { Function 3 = Get Mouse X,Y & Buttons }
    : Int $33 { Int $33 = Mouse Functions }
    : Shr Cx, 1 { Divide MouseX by 2 }
    : Les Di, MouseX { ES:DI = @MouseX }
    : Mov Es:[Di], Cx { MouseX is returned as 0-639, I want 0-319 }
    : Les Di, MouseY { ES:DI = @MouseY }
    : Mov Es:[Di], Dx { MouseY is returned as 0-199 }
    : Les Di, MouseB { ES:DI = @MouseB }
    : Mov Es:[Di], Bl { Mouse Buttons }
    : End;
    :
    : BEGIN
    :
    : begin
    : repeat
    : GetMouse(MouseX, MouseY, MouseB); { Sets the variables }
    : GotoXY(1, 1);
    : writeln(MouseX, MouseY); { Uses the location }
    : until MouseB > 0; { Checks if the user clicks to end the program }
    : end;
    : END.
    :
    : Now Ive integrated this code into a larger program which is probably too much of a hassle to post here. Part of this program is designed to store anything the user puts into the computer (ie the mouse click) and stores this in a .DAT file. Part of the code I use to store anything in these DAT files requires me to assign "MouseB" to "Answer[runs]" Answer[runs]:=MouseB;
    :
    : Pascal will not accept this calling it a type mismatch... What do I need to change???
    :
    :
    Change the type of the Answer elements to match the type of the MouseB.
  • NinthAngleNinthAngle Posts: 98Member
    : : I am trying to store the number of times a user of a program ive written clicks the 'left' or 'right' mouse button. To see whether or not the user presses a mouse button I am using the following code:
    : :
    : : PROGRAM Mouze;
    : : USES Crt;
    : : VAR MouseX, MouseY: Word;
    : : MouseB: Byte;
    : : key: char;
    : :
    : :
    : : PROCEDURE GetMouse(VAR MouseX, MouseY : Word; VAR MouseB : Byte); Assembler;
    : : ASM
    : : Mov Ax, $0003 { Function 3 = Get Mouse X,Y & Buttons }
    : : Int $33 { Int $33 = Mouse Functions }
    : : Shr Cx, 1 { Divide MouseX by 2 }
    : : Les Di, MouseX { ES:DI = @MouseX }
    : : Mov Es:[Di], Cx { MouseX is returned as 0-639, I want 0-319 }
    : : Les Di, MouseY { ES:DI = @MouseY }
    : : Mov Es:[Di], Dx { MouseY is returned as 0-199 }
    : : Les Di, MouseB { ES:DI = @MouseB }
    : : Mov Es:[Di], Bl { Mouse Buttons }
    : : End;
    : :
    : : BEGIN
    : :
    : : begin
    : : repeat
    : : GetMouse(MouseX, MouseY, MouseB); { Sets the variables }
    : : GotoXY(1, 1);
    : : writeln(MouseX, MouseY); { Uses the location }
    : : until MouseB > 0; { Checks if the user clicks to end the program }
    : : end;
    : : END.
    : :
    : : Now Ive integrated this code into a larger program which is probably too much of a hassle to post here. Part of this program is designed to store anything the user puts into the computer (ie the mouse click) and stores this in a .DAT file. Part of the code I use to store anything in these DAT files requires me to assign "MouseB" to "Answer[runs]" Answer[runs]:=MouseB;
    : :
    : : Pascal will not accept this calling it a type mismatch... What do I need to change???
    : :
    : :
    : Change the type of the Answer elements to match the type of the MouseB.
    :

    Both MouseB and Runs are of "Byte"


  • zibadianzibadian Posts: 6,349Member
    : : : I am trying to store the number of times a user of a program ive written clicks the 'left' or 'right' mouse button. To see whether or not the user presses a mouse button I am using the following code:
    : : :
    : : : PROGRAM Mouze;
    : : : USES Crt;
    : : : VAR MouseX, MouseY: Word;
    : : : MouseB: Byte;
    : : : key: char;
    : : :
    : : :
    : : : PROCEDURE GetMouse(VAR MouseX, MouseY : Word; VAR MouseB : Byte); Assembler;
    : : : ASM
    : : : Mov Ax, $0003 { Function 3 = Get Mouse X,Y & Buttons }
    : : : Int $33 { Int $33 = Mouse Functions }
    : : : Shr Cx, 1 { Divide MouseX by 2 }
    : : : Les Di, MouseX { ES:DI = @MouseX }
    : : : Mov Es:[Di], Cx { MouseX is returned as 0-639, I want 0-319 }
    : : : Les Di, MouseY { ES:DI = @MouseY }
    : : : Mov Es:[Di], Dx { MouseY is returned as 0-199 }
    : : : Les Di, MouseB { ES:DI = @MouseB }
    : : : Mov Es:[Di], Bl { Mouse Buttons }
    : : : End;
    : : :
    : : : BEGIN
    : : :
    : : : begin
    : : : repeat
    : : : GetMouse(MouseX, MouseY, MouseB); { Sets the variables }
    : : : GotoXY(1, 1);
    : : : writeln(MouseX, MouseY); { Uses the location }
    : : : until MouseB > 0; { Checks if the user clicks to end the program }
    : : : end;
    : : : END.
    : : :
    : : : Now Ive integrated this code into a larger program which is probably too much of a hassle to post here. Part of this program is designed to store anything the user puts into the computer (ie the mouse click) and stores this in a .DAT file. Part of the code I use to store anything in these DAT files requires me to assign "MouseB" to "Answer[runs]" Answer[runs]:=MouseB;
    : : :
    : : : Pascal will not accept this calling it a type mismatch... What do I need to change???
    : : :
    : : :
    : : Change the type of the Answer elements to match the type of the MouseB.
    : :
    :
    : Both MouseB and Runs are of "Byte"
    :
    :
    :
    And Answer? Runs isn't set in that assignment, but Answer is.
Sign In or Register to comment.