Scopes in Watch

Top  Previous  Next

The watch facility is only active when the Virtual Machine is not running, i.e. the execution is stopped. Naturally, the TIDE cannot fetch variable values while the Virtual Machine is executing your program.

You already know that when the Virtual Machine it stopped, the state of your target may be either  "BREAK" or "PAUSE". Properties and global variables may be inspected in the either state. Local variables only exist in their context. Hence, a particular local variable can only be inspected when the state is "BREAK" (the Virtual Machine is in the middle of a code execution -- there is an execution pointer visible) and when this variable exists in the current context.

For example:

 

 

sub sub_one

       dim x as byte

       x = 1

end sub

 

sub sub_two

       dim x as byte

       x = 2

end sub

 

sub sub_two

       dim i as integer

       i = 5

end sub

 

 

Let us say you add x to the watch list.

When the execution pointer highlights the end sub keyword for sub_one, the value of x in the watch would be 1. When the pointer highlights the end sub for sub_two, the value of x in the watch would be 2. Note that these are two different local variables!

Similarly, when the execution pointer is at the end sub of sub_three, the x variable in the watch will be undefined -- it will display a question mark.

These same rules apply to the watch tooltip, as well. Even if you hover the mouse over the x of sub_one when the program pointer is at the end of sub_two, the value displayed would be the one set in sub_two -- because this is the current context!