Every programmer will need at some point to automate tasks using his own personal standards. OptiPerl includes an OLE automation interface so you can control the editor using a high level language (like perl) using Object Linking & Embedding.

 

icon_arrow In the folder you installed optiperl, check out the "plug-ins" folder. This is where all perl and other plug-ins are stored. Many examples are included showing how to use plug-ins. Also check out the web page:

 

http://www.xarka.com/optiperl/plugins/

 

 

Using Plug-Ins

 

Below is a basic template for a plug-in:

 

#Name: Plug-in Name

#Description: Plug-in Description

#Icon: %opti%Tools.icl,148

#Button: Editor / Main menu

use Win32::OLE;

sub Initialization

{

$PlugID = $_[0];

#Get plug id. Will be used later

$optiperl = Win32::OLE->new('OptiPerl.Application');

#get reference to application

$optiperl->OutputAddLine("Hello World!");

$optiperl->MessageBox("My Plug-In","Hello World!",0);

$optiperl->EndPlugIn($PlugID);

}

sub Finalization

{

}

if (! defined $valid_plugin)

{

#enter here the subroutines you want to test.

Initialization;

}

 

The first 4 lines with comments are required and parsed for a definition of the plug-in. The lines are name, description, an icon that will be used as a button, and where to add the button. Here Editor / Main menu means that the button will be placed in the editor window, in the main menu (the toolbar over the editor window).

 

Also note the Initialization and Finalization subroutines. These are required in every plug-in. Because all code is event-driven, there is no need to place code outside of subroutines. The last line is for debugging purposes only; the value $valid_plugin is "magic" and defined only when the plug-in is run via the "Start/Stop" plug-in menu.

 

To run this plug-in, save in the \plug-in folder, and press once Tools / Start Stop Plug-ins / Update.

 

 

 

 

Top  Previous  Next