#  **************************************************
#  ** This function trys to close any open Dialogs **
#  **************************************************
public function Close_All_Dialogs ()
{
	auto i;
	static ArrayX[] = {
		"Notepad Help","About Notepad","Find",
		"Open","Save As","Page Setup" };

	for ( i in ArrayX )
	{
		if ( win_exists ( ArrayX[i], -1) == E_OK )
		{
			win_activate ( ArrayX[i] );
			set_window ( ArrayX[i], 1 );

			while ( win_exists ( ArrayX[i], -1) == E_OK )
			{
				win_close ( ArrayX[i] );
				printf ( "Trying to close window %s", ArrayX[i] );
				wait ( 0,500 );
			}
		}
	}
}

public function Notepad_Help ( in rc, in func )
{
	printf ( "In Exception Handler Notepad_Help" );
	win_close ( "Notepad Help" );
}

public function About_Notepad ( in rc, in func )
{
	printf ( "In Exception Handler About_Notepad" );
	win_press_ok("About Notepad");
}

public function Find ( in rc, in func )
{
	printf ( "In Exception Handler Find" );
	win_press_cancel ( "Find" );
}

public function Open ( in rc, in func )
{
	printf ( "In Exception Handler Open" );
	win_press_cancel ( "Open" );
}

public function Font ( in rc, in func )
{
	printf ( "In Exception Handler Font" );
	win_press_cancel ( "Font" );
}

public function Save_As ( in rc, in func )
{
	printf ( "In Exception Handler Save_As" );
	win_close ( "Save As" );
}

public function Page_Setup ( in rc, in func )
{
	printf ( "In Exception Handler Page_Setup" );
	win_press_cancel ( "Page Setup" );
}

#  **************************************************
#  ** Start of Test Script                         **
#  **************************************************

public ddd;

ddd = 0;

Close_All_Dialogs();

# Once an Exception is defined it exists...
# The only thing you can do is turn it on or off...
define_popup_exception ( "About_Notepad", "About_Notepad", "About Notepad" );
define_popup_exception ( "Find", "Find", "Find" );
define_popup_exception ( "Open", "Open", "Open" );
define_popup_exception ( "Save_As", "Save_As", "Save As" );
define_popup_exception ( "Font", "Font", "Font" );
define_popup_exception ( "Notepad_Help", "Notepad_Help", "Notepad Help" );
define_popup_exception ( "Page_Setup", "Page_Setup", "Page Setup" );

exception_on ( "About_Notepad" );
exception_on ( "Find" );
exception_on ( "Open" );
exception_on ( "Save_As" );
exception_on ( "Notepad_Help" );
exception_on ( "Page_Setup" );
exception_on ( "Font" );

# Test will loop in here until an Exception occurrs...
while ( ddd == 0 )
{
	wait (0,500);
	wait (0,500);
}
# The Exception Handler will be called, handle the Exception
# then test will return to the loop...

exception_off ( "About_Notepad" );
exception_off ( "Find" );
exception_off ( "Open" );
exception_off ( "Save_As" );
exception_off ( "Notepad_Help" );
exception_off ( "Page_Setup" );
exception_off ( "Font" );

# ****************************************************************************
# ** Create a GUI map of the Windows in Notepad                             **
# ****************************************************************************





