Come out of Infinite Loop

Pavan Yadav

Member
Hi All,
Please let me know, is there any way to come out of Infinite loop with some keys pressing in between.
For ex.:

do while i = 1:
display 'hello'.
pause 0.
on f8 stop.
end.

In this if i am giving pause greater than 0, then it stops the process. But, if i gives Pause 0 then it will not work.
& i want exactly that, it stops the process & quit from the window.
I knows only one way as cntrl + break, but i want to use some key instead of cntrl + break.
 
You could also do something like:
Code:
do while true:
  display " hello".
  readkey pause 0.
  if lastkey = 308 then leave.
end.

308, as I recall, is the key code for F8.

You might want to only do the check every N iterations. Doing it on each pass can be expensive.
 
Thanks tamhas & Bascom,
Bascom,
please let me know what this

readkey pause 0.

does & how it works over here. I am new, so unable to get the true picture of this.
 
From documentation for READKEY:

Reads one keystroke from an input source and sets the value of LASTKEY to the keycode of that keystroke. Use the READKEY statement when you want to look at each keystroke a user makes and take some action based on that keystroke.
PAUSE 0 makes sure that the message "press space bar to continue ..." will not appear.


HTH, RealHeavyDude.
 
Back
Top