Please enable JavaScript to view this site.

IBM® SPSS® Amos™ 28

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.
 
PluginsPlugins

2.In the Plugins dialog, click Create. The plugin editor opens.
 
clip0001

3.Add code for the Name, Description and Mainsub methods as shown in the following figure.
 
clip0002
 
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.
 
clip0003

5.Insert code for the MouseUp method as follows.
 
clip0004

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.
 
clip0005

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.
 
clip0006

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:
 
clip0007

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.
 
clip0008

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.
 
clip0009
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.)
 
clip0010
 
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.

© 2021 Amos Development Corporation