Home
What's new?
Help
Plug-ins
Plug-in Tutorial
- introduction
- talking to AEP
- processing
- making it better
- another removal
- add an extension
- some tips
Download
|
Processing the extension
You are almost done with your first plug-in. You've told AEP what this plug-in can do, now you've got to make sure the plug-in actually does it. When AEP notices the user has removed the extension gz from a file, and your plug-in is selected as the handler plug-in by the user in the plug-in preferences, AEP will load your plug-in and run the DoYourStuff function. As this function is larger than the previous one, we'll take it a bit at a time. It starts out like this:
The first line tells Applescript the name of the function and the information it should supply to it. In this case the item that will be processed, the CurrentItem, the folder that originally contained that item, the OriginalItemContainer, and the extension that the plug-in is supposed to process, the ExtensionToProcess. (Note, I'm taking a few shortcuts in the explanation here. Though this is what basically happens, there is a lot more going on behind the scenes. If you want to know more, you need to get more information on Applescript.)
Don't worry about the lines that start with --, they are just comments.
When your plug-in has finished, AEP expects it to return either the file or folder as it is after processing, or one of four error codes, these are defined in the beginning of the DoYourStuff function. Even though you're not going to do anything with them in this tutorial, you might want to know something about them. They are:
-
WRONG_ITEM_TYPE with a value of -1. This is used when AEP wronlgy passes you an item that the plug-in can't handle. At the moment, this will result in AEP telling the user that an error has occurred, so try not to use this one, but in the future things might change.
-
ERROR_HANDELING_ITEM with a value of -2. This is used if an error occured while processing the file or folder. AEP will then tell the user something has gone wrong, and to please help it to save as much as possible from this terrible mishap.
-
CANNOT_TELL_YOU_RESULTANT_ITEM with a value of -3. Again, use sparingly. In most cases your plug-in will be far smarter than AEP in figuring out which item to return. If you really can't, return this error, and AEP will try to do it for you. When it can't find the item, it will act like an ERROR_HANDELING_ITEM has been returned.
-
DO_NOT_WORRY_BE_HAPPY with a value of -4. In some cases, few I hope, plug-ins will deal with items in such a way, that nothing else can be done with them, e.g. deleting them or locking them into place. In these cases return this error, and AEP will ignore any other changes the user made to item. AEP will delete the temporary folder it created, so if you leave the item in there, it will be gone. Take care.
OK, on with something more interesting: the second thing you have to fill in to get this plug in working. it is on the next line.
As you might have guessed, you need to substitute the application name for PUT APPLICATION NAME HERE, as always taking care of the double quotes. It is probably easiest to just copy the name in the Finder and past it in Script Editor. And that's it! You can save the plug-in, drop it in the Removable Extensions folder of the plug-ins, start AEP and use it.
When playing with your new plug-in, note that Nutcase Gzip functions best if you limit the length of your file names to 28 characters. (The OS X gzip plug-in that was included in the AEP package doesn't have this limitation.) When you're done, you can go on with the third part of this tutorial.
|