In QB.EXE 4.5, Watchpoint Won't Break on Function Return Value (80848)
This article was previously published under Q80848
SYMPTOMS
In QB.EXE, setting a watchpoint to stop on a variable whose value is
assigned from the return value of a function will not break, even if
the Watch window shows that the expression evaluates to TRUE.
STATUS
Microsoft has confirmed this to be a bug in the QB.EXE environment
in Microsoft QuickBasic version 4.5 for MS-DOS. This problem was
corrected in QBX.EXE in Microsoft Basic Professional Development
System (PDS) version 7.1 for MS-DOS (fixlist7.10).
MORE INFORMATION
Setting a watchpoint creates a break in your program when certain
conditions are met. For example, in your program you may want a For
Loop that executes 100 times. If you want the program to stop after
the loop had executed 50 times, you could set a watchpoint with the
expression X=50, where X is the loop counter.
However, when you try to set a watchpoint on a variable that is set
from the return value of a user defined function, when the Watch
window evaluates the expression to TRUE, the program will not break.
WORKAROUND
To work around this problem, assign the results of the function to a
temporary value and then assign the temporary value to x%. This will
allow you to stop execution when the expression becomes TRUE.
FUNCTION num%
temp% = 5
x% = temp%
END FUNCTION
Steps to Reproduce Problem- In the QuickBasic environment, enter the following program.
DECLARE FUNCTION num% ()
WHILE INKEY$ = ""
x% = num%
WEND
FUNCTION num%
num% = 5
END FUNCTION
- From the Debug menu, choose Watchpoint, and add a watchpoint. At
the prompt to enter the expression, type x%=5.
- From the Run menu, choose Start.
- Press any key to end the program.
In this example, notice that after the program terminates, the Watch
window reads TRUE signifying that the expression was TRUE and the
program should have stopped. To demonstrate the proper functionality
of this operation, change the "x% = num%" in the Basic source code to
be x%=5.
Modification Type: |
Minor |
Last Reviewed: |
1/9/2003 |
Keywords: |
KB80848 |
|