ID: Q121227
The information in this article applies to:
In the following code example, pressing CTRL+C or any other key combination that is defined to terminate the DO WHILE loop will cause a "Nesting error" message. In this example, CTRL+C has been used as a "natural" key combination, although CTRL+D, CTRL+Q, or any other key combination will also produce the same error.
ON KEY LABEL ctrl+C EXIT
DO WHILE .T.
WAIT WINDOW "hello" NOWAIT
ENDDO
To set up a DO WHILE control structure that will terminate when a key combination is pressed, create a variable and initialize it to true (.T.). In the ON KEY LABEL statement, reassign the memory variable to false (.F.).
memvar = .T.
ON KEY LABEL ctrl+C memvar = .F.
DO WHILE memvar
WAIT WINDOW "HELLO" NOWAIT
ENDDO
Another way of achieving the same result is shown in this second example.
In the following code, VAR1 is initialized to null. When the CTRL+C key
combination is pressed, VAR1 is assigned the command to be executed. Until
VAR1 is assigned something to do, nothing gets done. Upon assignment, the
command is executed and the loop is terminated. This indirection also works
for other commands as well.
var1=""
ON KEY LABEL ctrl+C var1="EXIT"
DO WHILE .T.
WAIT WINDOW "Hello World" NOWAIT
&var1
ENDDO
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
Additional reference words: FoxDos FoxWin buglist2.00 buglist2.50 buglist2.50a buglist2.50b buglist2.60 buglist2.60a 2.00 2.50 2.50a 2.50b 2.60 2.60a errmsg KBCategory: kbenv kbprg kberrmsg kbbuglist KBSubcategory: FxenvMemory
Last Reviewed: August 28, 1995