hasch and getch program
Author |
Message |
slimshadyy
|
Posted: Thu Apr 18, 2013 9:20 am Post subject: hasch and getch program |
|
|
What is it you are trying to achieve?
create a program which starts with a blank output window. check whether a key has been pressed, and if the D key (or d key) has been pressed, draw a graphic of some kind (oval, square, maple leaf) in a random position on the screen. if the D (or d) key is pressed again, clear the screeen and draw the image again in another random position. if X or x is pressed, exit the program.
What is the problem you are having?
i cannot get the program to exit when you press 'x' or 'X'
Describe what you have tried to solve this problem
i tried placing an exit statement, but i dont think its in the right spot.
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
var input : string (1) := ' '
var x, y : int
x := 50
y := 50
loop
if hasch then
getch (input)
put "The key you entered was ", input
delay (500)
if input = 'd' or input = 'D' then
drawfillmapleleaf (x, y, 200, 200, 31)
randint (x, 1, maxx)
randint (y, 1, maxy)
drawfillmapleleaf (x, y, 200, 200, 12)
exit when input = 'x' or input = 'X'
end if
end if
end loop
put "Goodbye"
Please specify what version of Turing you are using
4.11 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
TW iz Rippin
|
Posted: Thu Apr 18, 2013 10:01 am Post subject: RE:hasch and getch program |
|
|
Simple... your exit when statement is in the wrong location. |
|
|
|
|
|
slimshadyy
|
Posted: Thu Apr 18, 2013 11:09 am Post subject: Re: hasch and getch program |
|
|
does it go after the loop? |
|
|
|
|
|
Raknarg
|
Posted: Thu Apr 18, 2013 12:09 pm Post subject: RE:hasch and getch program |
|
|
look at where it's placed.
Try running this:
var ch : string (1)
loop
getch (ch)
if ch = "f" then
if ch = "q" then
put "hi"
end if
end if
end loop
Will this program ever put "hi"? This is essentially what your program is doing right now. |
|
|
|
|
|
TW iz Rippin
|
Posted: Thu Apr 18, 2013 4:20 pm Post subject: RE:hasch and getch program |
|
|
Well, if you put the exit when statement just before the end loop it will work, basically, it is not reaching your statement. |
|
|
|
|
|
Raknarg
|
Posted: Thu Apr 18, 2013 6:47 pm Post subject: RE:hasch and getch program |
|
|
yeah, except I'd rather he figure that out |
|
|
|
|
|
TW iz Rippin
|
Posted: Fri Apr 19, 2013 9:55 am Post subject: RE:hasch and getch program |
|
|
I know but he should have got it after my post lol |
|
|
|
|
|
Raknarg
|
Posted: Sat Apr 20, 2013 1:16 pm Post subject: RE:hasch and getch program |
|
|
Your point? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
slimshadyy
|
Posted: Sun Apr 21, 2013 1:14 pm Post subject: Re: hasch and getch program |
|
|
lool, btw i'm a girl. |
|
|
|
|
|
Raknarg
|
Posted: Sun Apr 21, 2013 3:04 pm Post subject: RE:hasch and getch program |
|
|
Well I'm not about to call you an it |
|
|
|
|
|
slimshadyy
|
Posted: Mon Apr 22, 2013 6:33 pm Post subject: Re: hasch and getch program |
|
|
lool true truee. |
|
|
|
|
|
|
|