Problem closing Event Log windows

I am trying to write a script that tidies up my Script Debugger windows. What I want to do is to position the active script in the centre of the screen, then close all the event log windows except the one for the active script and place that one to the left of the active script window.

My problem is with closing the Event Log windows. If I just say ‘close’ I get told “The ‘saving’ parameter must not be ‘ask’ when Script Debugger sends a ‘close’ event to its self.” but if I say ‘close without saving’ I find that the windows of other unsaved scripts get closed. And if I say ‘close with saving’ it seems to be trying to close the script window rather than the Event Log window

I assume I have hold of the wrong end of some stick, I’m just not sure which one!

(Thanks to Shane Stanley for the screen resolution handler. And for much else of course.)

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use framework "AppKit"
use scripting additions

property ScreenWidth : missing value
property ScreenDepth : missing value
log ScreenWidth
log ScreenDepth
property LogWidth : missing value
set LogWidth to (ScreenWidth / 4)
property EditorWidth : missing value
set EditorWidth to (ScreenWidth / 2)
property BufferWidth : 10
property StartTop : 30

tell application "Script Debugger"
	tell (item 1 of (every script window))
		set parent bounds to {(LogWidth + (BufferWidth)), StartTop, (LogWidth + (BufferWidth * 2)) + EditorWidth, (ScreenDepth - BufferWidth)}
	end tell
		set AllLogWindows to every event log window
		if AllLogWindows is {} then
			exit repeat
			tell (item 1 of AllLogWindows)
				close without saving
			end tell
		end if
	end repeat
	tell document 1
		set NewLog to (make new event log window)
	end tell
	tell NewLog
		set bounds to {BufferWidth, StartTop, LogWidth, ScreenDepth - BufferWidth}
	end tell
end tell

-- Return width and height of main screen
on GetMainScreenSize()
	set MainFrame to current application's NSScreen's screens()'s firstObject()'s frame()
	set ScreenWidth to (item 1 of (item 2 of MainFrame))
	set ScreenDepth to (item 2 of (item 2 of MainFrame))
end GetMainScreenSize