Own subroutines in ASOC?

What is right way to have own AppleScript subroutines in ASOC?

I just tried to put all of my own code to applicationShouldTerminate_(sender) and it works, but that surely is not right way to do it.


ASOC (like the old-fashioned AppleScript Studio) is handler based, so you can put your handlers where ever you want (on the top level of the script object), or define another script/class to put it there


Some thing like this?:

script testingAppDelegate
	property parent : class "NSObject"
	on applicationWillFinishLaunching_(aNotification)
		-- Insert code here to initialize your application before any files are opened
	end applicationWillFinishLaunching_
	on my_code()
		applicationShouldTerminate_() --and when i want to quit i use this?
	end my_code
	on applicationShouldTerminate_(sender)
		-- Insert code here to do any housekeeping before your application quits
		return current application's NSTerminateNow
	end applicationShouldTerminate_
end script

Right, except

 applicationShouldTerminate_() --and when i want to quit i use this?

Answer: No.

To terminate the app explicitly call this

current application's NSApp's terminate_(me)

Then applicationShouldTerminate_() is called automatically and expects an integer return value to indicate
¢ terminate now
¢ terminate later (e.g. to ask the user to save changes)
¢ don’t terminate