cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Controlling multiple executions of XUI code and event definitions

ptc-953343
1-Newbie

Controlling multiple executions of XUI code and event definitions

I have a XUI application that I start via a menu bar item. This is
functionality we would like to toggle on and off. So I'm trying to
find a way (in this case with a variable to trap the status of the application.
1 REPLY 1

Hi Dan--

By including the "var" keyword inside your if body, you are essentially creating a new, locally-scoped variable instead of assigning a value to a global variable. Try removing the "var" and I think it will work the way you intend, assigning the "true" value to the global variable.

(Note that your code assigns the string "true" to the variable rather than the logical true value, which may not be what you intend. If you really want to make it boolean, use the keyword true without the quotation marks.)

Also, there's a potential gotcha here--if this control needs to be attached to multiple windows, with each window having its own independent status to keep track of, then this approach won't work. If you have the control attached to window A, and window B checks, it will think the control is already there because window A already set the global variable. We get around this by using arrays indexed by doc ID. So instead of

ReviewerActive = true;

we would use

ReviewerActive[current_doc()] = true;

and similarly, any code that checks for the presence of the control would use the array with the doc ID as index.

--Clay
Announcements