Xbasic Script Context
When you run a script that is attached to a toolbar button, the script has the same context as the active window. The aliases this and parentform, used in a script attached to a toolbar button, refers to the active window. For example, assume that you have a toolbar with this Xbasic code attached to one of the buttons on the toolbar:
name = this.name() ui_msg_box("window name is:" , name)
When you press the toolbar button, it will report the name of the window that is active. The following example shows code that could be attached to a Query By Form toolbar to insert the "Is not blank" search operator into the field that currently has focus:
'Determine which object currently has focus active_object = parentform.active() 'Get a pointer to that object ptr = obj(active_object) 'Set the text property of that object ptr.text = "Is not blank"