# Copyright 2000 Earthstar Geographics.
#
# Script:  ESG_Close_All_Windows.erb
# Date:    March 2000
# Author:  Eric Augenstein (eric@es-geo.com)
# Summary: Closes (delets) all image windows.  Prompts to
#	     be sure you want to di this.

$confirm_list[0] = "Close all windows"
$confirm_list[1] = "Cancel"
$confirm = $confirm_list[0]

include "lib/BE_Startup.erb"

if current window then goto ask_confirm
goto finished

ask_confirm:
	ask begin
	title "Confirm Close All Windows"
		say "Are you sure you want to close all windows?"
		say ""
		say "- Click 'Cancel' to exit out and save algorithms."
		say "- Click OK to proceed and close all windows."
#		say ""
#		ask listmenu_exclusive "" $confirm_list $confirm
	ask end

#if ($confirm == "Close all windows") then goto start_closing  
#goto finished 

start_closing:
$winlast = last window

# Unlink the first window (by window ID number).

$win1 = first window
$next = next window
select $win1
delete $win1

close_other_windows:
if ($next == $winlast) then goto close_last_win
$currwin = $next
select $currwin
$next = next window

delete $currwin

goto close_other_windows

close_last_win:
delete $winlast

finished:
exit
