Code fold change window tabs from script

How can I code fold script handlers by script and switch tabs of a window without system events?

tell application "System Events"
	tell application process "Script Debugger"
		--33 = [ previous tab
		key code 33 using {command down, option down} --
		delay 0.1
		--123 = left arrow fold handlers
		key code 123 using {command down, option down, shift down}
		delay 0.1
	end tell
end tell


There isn’t a scripting interface for controlling code folding.

You can control the selected tab within a script window by setting the script window object’s current document property to a reference to a document within the window.

This little bit of code will randomly change tabs:

tell script window 1
	set current document to some document
end tell