
-----------------------------------
vdemons
Mon May 23, 2011 5:13 pm

How would i go about making a pause button or pause key?
-----------------------------------
I have been thinking about this for a while, and have done two attempts, both only paused when the button (when made as a button) was held and both didn't work at all (just as a procedure) so I would like to ask how do make a pause button here were my methods. 

#1

procedure pausing
    var key : string (1) := ""
    key := ""
    if hasch then
        getch (key)
    end if
    if key = ('p') then
        loop
            if key = ('p') then
                exit
            end if
        end loop
    end if
end pausing



and #2

procedure pausing
    if chars ('p') then
        loop
            if chars ('p') then
                exit
            end if
        end loop
    end if
end pausing



-----------------------------------
Raknarg
Mon May 23, 2011 5:35 pm

RE:How would i go about making a pause button or pause key?
-----------------------------------
You could still do it the way you have it set up, just you would need to use 2 keys instead of 1. When you press p, it pauses. However, it also unpauses whenever p is pressed. The problem is that the change is so fast, that the user doesn't have time to let go of the p key before the loop begins.

-----------------------------------
Tony
Mon May 23, 2011 5:46 pm

RE:How would i go about making a pause button or pause key?
-----------------------------------
That's not even the issue (although it often is).
[code]
if key = ('p') then 
        loop 
            if key = ('p') then 
[/code]
If "key = ('p')" is true the first time, it's guaranteed to also be true the second time.

-----------------------------------
vdemons
Mon May 23, 2011 5:50 pm

RE:How would i go about making a pause button or pause key?
-----------------------------------
oh I see whats happening now, is there a way to delay the change somehow

-----------------------------------
vdemons
Mon May 23, 2011 5:56 pm

RE:How would i go about making a pause button or pause key?
-----------------------------------
I tried changing the second p into something else like q but it would pause, and stay paused . . . forever. 

if key = ('p') then 
        loop 
            if key = ('q') then

-----------------------------------
Tony
Mon May 23, 2011 6:15 pm

RE:How would i go about making a pause button or pause key?
-----------------------------------
Think about all the conditions that need to hold true for the code to get to the "unpause"/exit part. Can this ever happen?

-----------------------------------
RandomLetters
Mon May 23, 2011 10:00 pm

RE:How would i go about making a pause button or pause key?
-----------------------------------
procedure pausing 
    if chars ('p') then 
        loop 
            if chars ('p') then 
                exit 
            end if 
        end loop 
    end if 
end pausing 

How do you know what the person is pressing?
