This section shows you how to use Amos's built-in editor to write a plugin in Visual Basic. Writing a plugin in C# is similar.
1.On the Amos Graphics menu, click Plugins -> Plugins. The Plugins dialog opens.
2.In the Plugins dialog, click Create. The plugin editor opens.
3.Add code for the Name, Description and Mainsub methods as shown in the following figure.
Amos calls the Name function to obtain the name of the plugin. The plugin's name will appear on the Amos Graphics Plugins menu. In the present example "A simple plugin" will be placed on the Plugins menu. It is OK if the Name function returns an empty string (""). In that case, the name of the file that contains the plugin will be placed on the Plugins menu.
Amos calls the Description function to obtain a description of the plugin. A plugin's description is typically longer than its name. A plugin's description is displayed when the plugin is selected from the list in the Plugins dialog. It is OK for the Description function to return an empty string ("").
Amos calls the Mainsub function when you select A simple plugin from the Plugins menu. In this example, clicking A simple plugin on the Plugins menu will display the message "Installing a simple plugin".
4.Scroll down through the source code until you locate the MouseUp method.
5.Insert code for the MouseUp method as follows.
6.To let Amos know that it should call the MouseUp method when you release the mouse button, use the AddHandler keyword as shown in the following figure.
7.The plugin as specified up to this point displays a message every time you release the mouse button. You can stop this behavior only by closing Amos Graphics and re-opening it. However, you can cause the plugin to stop responding to mouse clicks by using the RemoveHandler keyword. Just as the AddHandler keyword causes Amos to call the pd_MouseUp method for every mouse click, the RemoveHandler keyword can be used to cause Amos to stop calling the pd_Mouseup method. In the following figure, RemoveHandler is executed immediately after the first "mouse up" message appears. As a result Amos calls the pd_MouseUp method for a single mouse click only.
8.You may if you wish delete any method other than Name, Description, Mainsub and MouseUp. Amos always calls Name, Description and Mainsub, and so they must be present. In the present example, it is possible that MouseUp will be called because of the AddHandler line in Mainsub. The other methods will never be called and can be deleted, making the code for the plugin look like this:
9.Click the Check Syntax toolbar button to check for syntax errors. Any error messages will be displayed in the Syntax Errors area. If there are no syntax errors, you will see the message Syntax is OK.
10. After correcting any typing mistakes so that pressing the Check Syntax toolbar button produces the message Syntax is OK., close the plugin editor window (by clicking the "x" in the upper-right corner). You will be asked if you want to save the plugin.
Click Yes.
11. The Save As dialog opens, with the Amos Plugins directory as the default directory. (Plugins must be saved in the Plugins directory.)
Enter a file name for the plugin and click Save. (The file name SimplePlugin was entered in the figure above.)
12. Close the Plugins dialog.
13. To test the new plugin, click A simple plugin on the Plugins menu.