Quiting an Application

Hi Folks,

in my application there are

on click handler

on idle handler

on launch theApplication handler

I have added the following code inside the “on launch theApplication” handler:


if Q contains "T-Mobile A" then
		tell current application
			display dialog "Möchten Sie sich mit " & Q & " verbinden? Dies kann zu hohen Kosten führen" buttons {"Cancel", "Ja"} default button "Cancel"
			set the requested_status to the button returned of the result
		end tell
		--display dialog requested_status
		if the requested_status is "Cancel" then
			quit theApplication
		end if
	end if


When pressing the “Cancel” Button the “theApplication” will be ended, but the “on idle” is going through - I want the application to be quit, if pressed the “Cancel” Button…

What I am doing wrong?

Thanks for any suggestions,

Stefan

Hi Stefan,

the Cancel button causes error -128 (user cancelled) which aborts the script.
You can do this:

if Q contains "T-Mobile A" then
	try
		tell current application
			display dialog "Möchten Sie sich mit " & Q & " verbinden? Dies kann zu hohen Kosten führen" buttons {"Cancel", "Ja"} default button "Cancel"
			set the requested_status to the button returned of the result
		end tell
	on error number -128
		quit theApplication
	end try
end if

Grüße nach Österreich :slight_smile:

Hi Stefan,

It works perfect - thanks for the hint - I tried it before with

 error -128 

but without on and try

Schöne Grüße in die verschneite? Schweiz…

lg,

Stefan

in Sankt Gallen noch nicht :slight_smile: