Posted: Tue Jan 11, 2011 11:26 pm Post subject: RE:Urgent Turing Calculator Help
i read it and somewhat understand it now. i amstill trying to comprehend it some parts. i put my code inside the loop with the mousewhere and got the desired effect. the only thing now is how do you make the make the turing machine recognize what kind of number the mouse is at. and how to display it on the screen.
if (x >= 196) and (x < 210) and (y > 237) and (y < 259) then
put "8"
end if
i tried that. but it still does not show the answer in the box at the top. also how do i store the number. like for example say if the user enters a number, i want the number to be stored. do i have to put the num after the "8" or something like that
Sponsor Sponsor
Tony
Posted: Tue Jan 11, 2011 11:33 pm Post subject: RE:Urgent Turing Calculator Help
You would probably want to put that number into some kind of a variable; then you could work with the values in your variables.
Posted: Wed Jan 12, 2011 5:34 pm Post subject: RE:Urgent Turing Calculator Help
isnt int any whole number?
and real is any number, either a whole number or decimal
2goto1
Posted: Wed Jan 12, 2011 5:53 pm Post subject: RE:Urgent Turing Calculator Help
An integer can be either positive or negative, whereas a whole number is 0 or greater.
Wajih
Posted: Wed Jan 12, 2011 6:26 pm Post subject: RE:Urgent Turing Calculator Help
i made the necessary corrections to the code. now the thing is how do i make the numbers for num 2 appear because every time i hit a number it only goes to num. does anyone know why?
var num : real
var num2 : real := 0
var symbol : string
var x , y , button : int := 0
loop
Mouse.Where (x, y, button)
Text.Locate (22, 1)
if button = 0 then
put x : 0, " ", y : 0, " button up"
else
put x : 0, " ", y : 0, " button down"
end if
if (button = 1) and ( x >= 137) and ( x <= 158) and ( y >= 142) and ( y <= 163) then
locate (5, 19)
num := 1
put "", num
end if
if ( button = 1 ) and ( x >= 194) and (x <= 214) and ( y >= 142) and ( y <= 163) then
locate (5, 19)
num := 2
put "", num
end if
if ( button = 1 ) and ( x >= 251) and (x <= 272) and ( y >= 142) and ( y <= 163) then
locate (5, 19)
num := 3
put "", num
end if
if ( button = 1 ) and ( x >= 137) and (x <= 158) and ( y >= 190) and ( y <= 208) then
locate (5, 19)
num := 4
put "", num
end if
if ( button = 1 ) and ( x >= 194) and (x <= 214) and ( y >= 190) and ( y <= 208) then
locate (5, 19)
num := 5
put "", num
end if
if ( button = 1 ) and ( x >= 251) and (x <= 272) and ( y >= 190) and ( y <= 208) then
locate (5, 19)
num := 6
put "", num
end if
if ( button = 1 ) and ( x >= 137) and (x <= 158) and ( y >= 241) and ( y <= 258) then
locate (5, 19)
num := 7
put "", num
end if
if (button = 1) and( x >= 196) and (x < 210) and (y > 237) and (y < 259) then
locate (5, 19)
num := 8
put "", num
end if
if ( button = 1 ) and ( x >= 251) and (x <= 272) and ( y >= 241) and ( y <= 258) then
locate (5, 19)
num := 9
put "", num
end if
if (button = 1) and( x >= 298) and (x < 333) and (y > 234) and (y < 266) then
locate (5, 30)
symbol := "="
put "", symbol
end if
if (button = 1) and( x >= 387) and (x < 405) and (y > 190) and (y < 210) then
locate (5, 22)
symbol := "*"
put "", symbol
end if
if (button = 1) and( x >= 345) and (x < 367) and (y > 188) and (y < 210) then
locate (5, 22)
symbol := "/"
put "", symbol
end if
if (button = 1) and( x >= 305) and (x < 325) and (y > 142) and (y < 163) then
locate (5, 22)
symbol := "-"
put "", symbol
end if
if (button = 1) and( x >= 305) and (x < 325) and (y > 190) and (y < 210) then
locate (5, 22)
symbol := "+"
put "", symbol
end if
Mouse.Where (x, y, button)
Text.Locate (22, 1)
if button = 0 then
put x : 0, " ", y : 0, " button up"
else
put x : 0, " ", y : 0, " button down"
end if
if (button = 1) and ( x >= 137) and ( x <= 158) and ( y >= 142) and ( y <= 163) then
locate (5, 25)
num2 := 1
put "", num2
end if
if ( button = 1 ) and ( x >= 194) and (x <= 214) and ( y >= 142) and ( y <= 163) then
locate (5, 25)
num2 := 2
put "", num2
end if
if ( button = 1 ) and ( x >= 251) and (x <= 272) and ( y >= 142) and ( y <= 163) then
locate (5, 25)
num2 := 3
put "", num2
end if
if ( button = 1 ) and ( x >= 137) and (x <= 158) and ( y >= 190) and ( y <= 208) then
locate (5, 25)
num2 := 4
put "", num2
end if
if ( button = 1 ) and ( x >= 194) and (x <= 214) and ( y >= 190) and ( y <= 208) then
locate (5, 25)
num2 := 5
put "", num2
end if
if ( button = 1 ) and ( x >= 251) and (x <= 272) and ( y >= 190) and ( y <= 208) then
locate (5, 25)
num2 := 6
put "", num2
end if
if ( button = 1 ) and ( x >= 137) and (x <= 158) and ( y >= 241) and ( y <= 258) then
locate (5, 25)
num2 := 7
put "", num2
end if
if (button = 1) and( x >= 196) and (x < 210) and (y > 237) and (y < 259) then
locate (5, 25)
num2 := 8
put "", num2
end if
if ( button = 1 ) and ( x >= 251) and (x <= 272) and ( y >= 241) and ( y <= 258) then
locate (5, 25)
num2 := 9
put "", num2
end if
Posted: Wed Jan 12, 2011 6:57 pm Post subject: RE:Urgent Turing Calculator Help
hard to tell for sure, but I don't think you are keeping track of the state that you are in. That is, when the loop is running, how do you know if the first number has already been selected or not?
Posted: Wed Jan 12, 2011 7:22 pm Post subject: RE:Urgent Turing Calculator Help
because it is displayed. the thing i need help is with how to make the first number(num), the symbol and the second number (num2) be seen at the same time. do i have to create a new variable? a new loop?