Re: loop never exits on ESC

From: Fred Taylor (ftaylor_at_mvps.org!REMOVE)
Date: 12/13/04


Date: Mon, 13 Dec 2004 00:42:36 -0700

Maybe your computer is too slow or too fast to "see" the key stroke. Try a
DOEVENTS inside your look and see if that helps. I've tried the code I sent
on a 333Mhz, 2.0Ghz, 2.5Ghz, and 3.0Ghz machines and it all works fine.

-- 
Fred
Microsoft Visual FoxPro MVP
"rajani" <rajani@discussions.microsoft.com> wrote in message 
news:40C6E3CF-3410-41C8-8286-3531DAA1968A@microsoft.com...
> Fred
> No,i've not used inkey() in my sample program.
> I tried ur code but have not got any wait window when i pressed ESC :-(
>
>
> "Fred Taylor" wrote:
>
>> If that's returning 27, then there is no other reason that I can think of
>> that would prevent it from working.
>>
>> Do you have an INKEY() inside your loop anywhere?  If you do, the INKEY()
>> will suck up your ESC and it probably won't work reliably.
>>
>> If you put this little example in a .PRG and run it, you should see a 
>> WAIT
>> WINDOW for about .5 second each time you press escape.  The program 
>> should
>> run for approximately 10 seconds total.
>>
>> SET ESCAPE ON
>> ON ESCAPE wait window "escape" timeout .5
>> FOR x=1 TO 100
>>   IF CHRSAW(.1)
>>     * just something to do for a 1/10 of second
>>   ENDIF
>> ENDFOR
>>
>> -- 
>> Fred
>> Microsoft Visual FoxPro MVP
>>
>>
>> "rajani" <rajani@discussions.microsoft.com> wrote in message
>> news:9C2E4772-C1B1-476A-909C-72BF2AADF4EC@microsoft.com...
>> > Fred
>> > when i just tried that i thought it frozen as could not click on 
>> > anything.
>> > but when i pressed ESC i got 27
>> >
>> > "Fred Taylor" wrote:
>> >
>> >> On the machine that doesn't work, what do you get with this line of 
>> >> code:
>> >>
>> >> ?INKEY(0)
>> >>
>> >>
>> >> -- 
>> >> Fred
>> >> Microsoft Visual FoxPro MVP
>> >>
>> >>
>> >> "rajani" <rajani@discussions.microsoft.com> wrote in message
>> >> news:11F29CEF-4B29-4234-BFD9-D08A728588BA@microsoft.com...
>> >> >I just made a small program which replicates my problem
>> >> > (no matter how many times i press ESC or INS the loop never 
>> >> > exits).but
>> >> > same
>> >> > piece of code works fine on my colleague's machine.
>> >> > LOCAL llCancel ,ncnt
>> >> > llCancel =.f.
>> >> > SET ESCAPE ON
>> >> > ON ESCAPE llCancel =.T.
>> >> > ON KEY LABEL INS llCancel =.T.
>> >> > ncnt=0
>> >> >
>> >> > * infinite loop through
>> >> > DO WHILE !llCancel
>> >> > ncnt = ncnt +1
>> >> >
>> >> > WAIT WINDOW NOWAIT "count value "+TRANSFORM(ncnt)
>> >> > DO WHILE !llCancel
>> >> > WAIT WINDOW NOWAIT "inside loop pal "+TRANSFORM(SECONDS())
>> >> > IF llCancel && this is never .T. :-(
>> >> > EXIT
>> >> > ENDIF
>> >> > ENDDO
>> >> > IF llCancel OR ncnt >1000
>> >> > EXIT
>> >> > ENDIF
>> >> > ENDDO
>> >> >
>> >> >
>> >> > "Sietse Wijnker" wrote:
>> >> >
>> >> >> Hi Tom,
>> >> >> Exactly like will only have effect on string comparison. When
>> >> >> comparing
>> >> >> numbers this will have no effect
>> >> >>
>> >> >>
>> >> >> "tom knauf" <tom.knauf@itds.de> wrote in message
>> >> >> news:cp925v$rdg$05$1@news.t-online.com...
>> >> >> > Hi,
>> >> >> >
>> >> >> > what happens if you put something like ? lnkey in the loop ?
>> >> >> > Did you try if lnkey == 27 (double =) ?
>> >> >> >
>> >> >> > Tom
>> >> >> >
>> >> >> <rest snipped>
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>> 


Relevant Pages


Quantcast