| 
 |  | 
After constructing the main screen, the next stage includes checking for authorization, collecting data, and entering the main procedure for event/callback driven processing. ``Template main procedure: Main'' shows the Main procedure used in the SCOadmin template.
Template main procedure: Main
proc Main {} {
	global appvals
	# Where are we?
	set appvals(localhost)	[SaHostGetLocalName]
	set appvals(managedhost) $appvals(localhost)
	# Collect command line options
	ParseCommandLine
	# Initialize UI, build main form, present initial view
	# Sample who module (who.tcl) needs to tweak a few things first
	if {$appvals(who)} {
		WhoInit
	}
	UiStart
	# Main UI is now presented and Locked
	# Time-consuming startup operations can now take place with
	# optional status messages
	#
	# Examples:
	# + check user authorizations
	# + collect data to populate main form widgets
	# + populate main form widgets with live data
	SaStatusBarSet [VxGetVar $appvals(vtMain) statusBar] [IntlMsg INIT]
	# Authorizations
	set authorized 1
	# Sample when using who module
	if {$appvals(who)} {
		set authorized [WhoAuthorized $appvals(managedhost)]
	}
	# Canonical error dialog and exit if not authorized
	if {!$authorized} {
		set dialog [VxGetVar $appvals(vtMain) vtMain].noAuths
		SaDisplayNoAuths dialog $appvals(title) UiCloseCB $appvals(managedhost)
                VtUnLock
                VtMainLoop
		return
	}
	# Refresh main form data
	UiRefreshCB
	# Set initial focus (list or menu bar)
	UiSetAppFocus
	# Set sensitivity of all main screen ui selection devices
	UiSensitizeFunctions
	# Setup complete
	# Wait for user events
        SaStatusBarClear [VxGetVar $appvals(vtMain) statusBar]
        VtUnLock
        VtMainLoop
}