Command Reference : Add-ins : Add-ins Design Support
  
Add-ins Design Support
 
Add-ins Registration Command
The Active Object Keyword
“_this” Keyword
Custom Object Output
EViews offers several programming language features that will aid you in developing and working with Add-ins.
Add-ins Registration Command
The addin command may be used to register an EViews program file as an Add-in. You may use the command to specify the Add-in file, Add-in type, menu text, user-defined command name, description, version number, documentation file, XML file, etc.
See addin.
The Active Object Keyword
“_this” Keyword
Central to the construction of an object-specific Add-in program is the ability to reference the object on which the program should act. If, for example, you wish to write an Add-in that computes a statistic based on the data in a series object, you must have a convenient method of referring to the series.
Accordingly, EViews provides an object placeholder keyword, _this, which refers to the currently active object upon which a program may operate. Typically the use of _this in an EViews program indicates that it has been designed to work with a single object.
There are three ways in which the identity of the _this object may be set:
_this refers to the active object whose window was last active in the workfile; when used in a program, _this refers to the active object at the time the program was run.
executing an Add-in using the object-command syntax, obj_name.proc, sets _this to obj_name.
_this can be set to a specific object using the “this=” option in an exec or run command.
While the above description is a bit abstract, a simple example should illustrate the concepts that lay behind the three methods. Suppose we have the trivial (silly) program “Myline.PRG” which consists of the command:
_this.line
First, if we register this program as a global Add-in with menu item text “Show line”, we can display a line graph of a series or group object by opening the series or group and selecting Show line from the Add-in menu. From the program’s point of view, the _this object is simply the opened series or group whose menu we are using (the last one active in the workfile).
Alternately, if we had registered the program as a series-specific Add-in with proc name “myl”, the command:
ser01.myl
identifies SER01 as the _this object, so that the object used by the Add-in will be the series SER01, regardless of which object is active in the workfile.
Lastly, you may specify _this explicitly when using the exec or run command to run the program by including the “this=” option to identify an object by name. The command:
exec(this=ser01) myline.prg
explicitly specifies SER01 as the _this object.
Custom Object Output
EViews allows you to display the contents of a table, graph, or spool object in the window of another object. This feature will undoubtedly most often be used to mimic the behavior of EViews views and procedures in Add-ins programs.
Suppose, for example, that your Add-in program performs some calculations and constructs an output table TABLE_OUT. You may instruct EViews to display the contents of TABLE_OUT in the object OBJECT_01 using the display command:
object_01.display table_out
Thus, a useful approach to constructing an object-specific Add-in involves creating a program of the form:
[use _this to perform various calculations]
[create an output table or graph, say the table TABLE01]
’ put the output in the _this window
_this.display table01
delete table01
Note that we delete the TABLE01 after we put it in the window of _this. (You may instead wish to employ local subroutine to enable automatic cleanup of the temporary table.)
If the above program is registered as a series-specific Add-in with the command “FOO”, then you may run it by issuing the command
series01.foo
which will display the output in the SERIES01 window.
The display object command is a documented view for each supported object. See for example, Series::display.