Defining conditions in "on alert ended"

I need to define the “on alert ended” handler to handle multiple alerts, each with different buttons and responses. As it stands, you can only have one handler for the event, so I need to execute the actions conditionally, but I can’t find anything in Apple’s documentation about how to tell the handler what to do for each individual alert. Basically, I need this line of code:

on alert ended theObject with reply theReply
	if [a certain alert which I don't know how to identify comes up]
		if button returned of theReply is alternateButtonTitle then
			tell application "Terminal"
				launch
				do script "sudo /usr/local/bin/vpn_uninstall" in window 1
				set frontmost of window 1 to true
			end tell
			quit
		else
			quit
		end if
	else [if the other error comes up]
		quit
	end if
end alert ended

And the first alert is invoked by this line

set theReply to display alert dialogText as dialogType message dialogMessage default button defaultButtonTitle alternate button alternateButtonTitle attached to window "mainWindow"

You can define a global which will pass information to the “alert ended panel”. Eg:


global panelType
global panelAuxiliarInfo

on clicked theObject --> eg, a button will display a panel or alert or whatever
     if name of theObject is "button will display alert"
          set panelType to "alert"
          display alert whatever
     end if
end

on alert ended theObject with reply theReply
     if panelType is "alert" then
          set infoINeed to panelAuxiliarInfo
     end if
end

If you are displaying, eg, a panel attached to a window with buttons and text fields and you click OK (eg, a button), you can handle such button to define “panelAuxiliarInfo”:


on clicked theObject
     if name of theObject is "buttonOKOfPanel" then
          set panelAuxiliarInfo to contents of text field "x" of window "I am a panel"
     end if
end

So, thanks to the defined global, you can get later the value of “panelAuxiliarInfo”, when you reach the “alert ended” handler.