ASOC app as file handler?

Hello everyone!

I’ve been searching on macscripter and the web for this. But I can’t seem to find anything about it.

I have a package (a folder that acts as a file, like an app) that I want to open using a AS (and ultimatly ASOC) application. Now, my app works when you drag the package to the app but not when you double click the package.
I Have no idea how I can tell launch services that my app can handle this file nor how my script can recognize that it has been called using a application.

global Serialkey
on open theDropped
	set droplet to "1"
	set SerialPath to (theDropped) & "Content:SerialCode:key.txt" as text
	
	try
		set fileRef to open for access file SerialPath
		set unparsedData to (read fileRef)
		set olddelim to AppleScript's text item delimiters
		set AppleScript's text item delimiters to ":"
		set UnparsedSerial to text item 1 of unparsedData
		set UnparsedSerialversion to text item 2 of unparsedData
		set AppleScript's text item delimiters to "="
		set Serialversion to text item 2 of UnparsedSerialversion
		set Serialkey to text item 2 of UnparsedSerial
		display dialog Serialkey
		close access fileRef
	on error
		try
			close access file SerialPath
		end try
	end try
	
end open
CheckKey()
on CheckKey_()
	try
		if droplet = "1" then
			
		end if
	on error
		set Serialkey to text returned of (display dialog "Please enter Serial Code." default answer "Serial Code")
	end try
	set database to (do shell script "curl rid-mac.com/Test/Projects/SerialValidator/Remote.txt")
	
	set md5hash to (do shell script "echo -n '" & Serialkey & "' | md5")
	if md5hash is in database then
		display dialog "Serial Code is correct"
	else
		display dialog "Serial Code is incorrect"
	end if
end CheckKey_

Currently it searches for a txt file containing a serial in the package, but in the future the package will contain more information (e.g. Settings, New scripts, etc).

Thanks in forward!

Xpresso,

That information is stored in the app’s Info.plist file. For ASObjC apps, there is a user interface in Xcode for setting document types, and you need to add that it is a package. Otherwise you’ll have to edit the Info.plist file yourself.

It’s a reasonably complex topic, but if you just want to be able to open the files, you can probably just add the extension under CFBundleTypeExtensions.