Xbasic
{WATCH}
Syntax
{WATCH= Variable ! Event_Name }
Arguments
- Variable
Character. The variable to monitor.
- Event_Name
Character. The name of the event to fire when Variable changes.
Description
The {WATCH} command monitors the value of a variable or expression and fires an event when that expression changes.
A5.TRANSACTION_COUNTER() can be useful in this context.
Example
dim global name as C name = "fred" ui_modeless_dlg_box("watch",<<%dlg% {watch=name!name_changed} Go to the Interactive window and change the value in the 'name' global variable.; {lf}; %dlg%,<<%code% if a_dlg_button = "close" then ui_modeless_dlg_close("watch") end if if a_dlg_button = "name_changed" then ui_msg_box("Note","Someone changed the value of the 'name' variable.") end if %code%)
A variation of this command monitors button clicks in another dialog box. This example is in two parts. First, start a modeless dialog box with buttons.
ui_modeless_dlg_box("test2",<<%dlg% {watch=ui_modeless_dlg_button("test")!buttonPressed} %dlg%,<<%code% if a_dlg_button = "close" then ui_modeless_dlg_close("test2") end if if a_dlg_button = "buttonPressed" then button_name = ui_modeless_dlg_button("test") if button_name <> "" then ui_msg_box("This is Test2 reporting what button was pressed in Test","Button that was pressed: " + button_name) end if ui_modeless_dlg_button_reset("test","") end if %code%)
Then start a script that watches for button clicks in the modeless dialog box.
ui_modeless_dlg_box("test",<<%dlg% %dlg%,<<%code% if a_dlg_button = "close" then ui_modeless_dlg_close("test") end if %code%)
Limitations
Desktop applications only
See Also