>How to close a Window whose WRITE event sends a CLOSE event to the form?

>In this situation the Window will close properly if the user closes through the Write event. However, if the user closes using the “X” at the top right of the window, OpenInsight will prompt “Save Changes?”. If the user selects ‘Yes’, the Close calls Write, which then calls Close again. OpenInsight will debug when Close tries to run twice.

The Solution? Just ask the window if it is closing! Use retstack to see which programs are running, if WINDOW.CLOSE is in the stack, you are already closing. The code is as follows:

0001  declare function retstack
0002  * Pre-write … Do some stuff …
0003  Call Forward_Event()
0004  * Post-Write … Do some stuff …
0005  stack = retStack()
0006  cmd = “CLOSE.WINDOW”
0007  is_closing = IndexC(stack,cmd,1)
0008  if is_closing else
0009  Call Send_Event(@window, ‘CLOSE’)
0010  end


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s