Contents Previous Next Subchapters

Creating And Listing Watch Points
Syntax watch
watch 
name
watch 
namefunction
watch 
namefunctionfile
watch 
name, , file
See Also dwatch , dall
Abbreviation wa
Menu Command Debug | SetWatchpoint . . .
Debug | ListWatchpoints

Description
If you set a watch on a variable, O-Matrix will suspend execution whenever that variable changes its values (unless that variable is the parameter in a function definition). The command
     watch
lists the variable watches that are currently set. The command
     watch 
name
sets a watch on the variable with the specified name where the variable is not inside of any function nor is it local to any file. The command
     watch 
namefunction
sets a watch on the variable with the specified name with and in the specified function where function is not local to any file. The command
     watch 
namefunctionfile
sets a watch on the variable with the specified name and with in the specified function where the function is local to the specified file. The command
     watch 
name, , file
sets a watch on the variable with the specified name and that is local to the specified file where the variable is not inside of any function.

Example Without File Specification
If the current directory is c:\omwin\programs and the file temp1.oms contains
     clear
     function fun(x) begin
          y = 5
          x = y^2
     end
     z = 7
     fun(z)
and at the DEBUG> prompt you enter
     watch y, fun
     watch z
O-Matrix will set a watch on the variable y in the function fun and one the global variable z. If you then enter
     watch
O-Matrix will respond with the following list
     Index   Variable     Function,  File
         1          y          fun,
         2          z             ,
If you quit the debugger and at the O> prompt you enter
     include temp1.oms
O-Matrix will execute the program until it completes the assignment to z. It will then stop execution and activate the Debugger window with the arrow pointing to the statement
     z = 7
In addition, it will print the message
     watch point: z, ,
If you then enter the command
     print z
O-Matrix will respond
     7
If you then enter the command
     continue
O-Matrix will execute the program until it completes the assignment to y in the function fun. It will then stop execution and activate the Debugger window with the arrow pointing to the statement
     y = 5
In addition, it will print the message
     watch point: y, fun,
If you then enter the commands
     print y
O-Matrix will respond
     5
which is the value that was assigned to y in the function fun.

Parameters
If a variable is a parameter with in a function, and the argument corresponding to the parameter is a variable; i.e., not an expression or a constant, you must set a watch point on the argument in order to stop when the parameter changes. If you continue the example above by entering
     continue
O-Matrix will stop execution with an arrow pointing to the statement
     x = y^2
and it will print the message
     watch point: z, ,
On the other hand, if you had deleted the watch point on z and set a watch point on the parameter x in the function fun above, O-Matrix would not have stopped at the assignment
     x = y^2

Example With File Specification
If the current directory is c:\omwin\programs and the file temp2.oms contains
     clear
     local function fun(x) begin
          y = 5
          x = y^2
     end
     local z = 7
     fun(z)
and at the DEBUG> prompt you enter
     watch y, fun, temp2.oms
     watch z, , temp2.oms
O-Matrix will set a watch on the variable y in the function fun and one the variable z in the file temp2.oms. If you then enter
     watch
O-Matrix will respond with the following list
     Index   Variable     Function, File
         1          y          fun, C:\OMWIN\PROGRAMS\TEMP2.OMS
         2          z             , C:\OMWIN\PROGRAMS\TEMP2.OMS
If you quit the debugger and at the O> prompt you enter
     include temp2.oms
O-Matrix will execute the program until it completes the assignment to z. It will then stop execution and activate the Debugger window with the arrow pointing to the statement
     local z = 7
In addition, it will print the message
     watch point: z, , C:\OMWIN\PROGRAMS\TEMP2.OMS
If you then enter the command
     print z
O-Matrix will respond
     7
If you then enter the command
     continue
O-Matrix will execute the program until it completes the assignment to y in the function fun. It will then stop execution and activate the Debugger window with the arrow pointing to the statement
     y = 5
In addition, it will print the message
     watch point: y, fun, C:\OMWIN\PROGRAMS\TEMP2.OMS
If you then enter the commands
     print y
O-Matrix will respond
     5
which is the value that was assigned to y in the function fun.