Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4095
Number of posts: 14004

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Type Mismatch Posted by NinthAngle on 27 Dec 2006 at 12:26 PM
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???

Report
Re: Type Mismatch Posted by zibadian on 27 Dec 2006 at 2:36 PM
: 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.
Report
Re: Type Mismatch Posted by NinthAngle on 29 Dec 2006 at 11:14 AM
: : 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"


Report
Re: Type Mismatch Posted by zibadian on 29 Dec 2006 at 12:24 PM
: : : 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.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.