DADiSP 6.5 B05 Release Notes
ActiveX Enhancements
REGISTEREVENT Handles Incoming ActiveX Events
REGISTEREVENT assigns an SPL function to execute when an external
AciveX event is fired.
Consider the following SPL event handler:
/* simple event handler */
MyEvent(argv)
{
local i, str = "";
loop (i = 1..argc)
{
str += sprintf("arg%d: %s ", i,
caststring(getargv(i)));
}
message("MyEvent", str);
} |
The handler can be used to process events from Internet Explorer.
/* connect to Internet Explorer */
ie = createobject("internetexplorer.application");
/* navigate to home page */
ie.navigate("www.dadisp.com");
/* show it */
ie.visible = 1;
/* establish event handler */
registerevent(ie, "TitleChange", "MyEvent"); |
Each time the title displayed by Internet Explorer changes,
MyEvent
is called and a message box is displayed.
The event can also be specified by an integer event ID. For example:
registerevent(ie, 0x71, "MyEvent"); |
UNREGISTEREVENT removes and SPL event handler.
FIREEVENT and RAISEEVENT Fire Outgoing ActiveX Events
FIREEVENT fires an ActiveX event with id numbers 1 through 8. Zero or
more arguments can be passed to the event handler. The arguments are
passed as a standard automation array of variants suitable for
most automation or script languages.
The following is an example of an event handler in VBA.
Public WithEvents DSP As DADiSPApp
''' initialize server
Sub InitDSP()
Set DSP = New DADiSPApp
DSP.Visible = True
End Sub
''' handler for event 3
Sub DSP_Event03(ParamArray args() As Variant)
Dim i As Integer
Dim s As String
s = ""
For i = 0 To UBound(args)
s = s + CStr(args(i))
Next i
MsgBox s, vbOKOnly, "Event 3 Fired"
End Sub |
To properly setup the event handler, add a Reference to the DADiSP
Type Library.
In DADiSP, executing the statement:
causes the
DSP_Event03 VBA code to execute and display a message box.
The statement:
fireevent(3, "test", 2.5) |
causes the
DSP_Event03 VBA code to execute and display the text:
test 2.5
RAISEEVENT uses id number 9 through 16 and provides the optional
arguments as a SafeArray of variants suitable for .NET languages.
GETCONTROL Returns the Current ActiveX Object
An SPL event handler can retrieve the handle to the calling ActiveX control
or server with GETCONTROL.
Consider the following SPL event handler:
/* simple event handler */
MyEvent(argv)
{
local i, str = "";
loop (i = 1..argc)
{
str += sprintf("arg%d: %s ", i,
caststring(getargv(i)));
}
/* get calling ActiveX object */
ctrl = getcontrol();
/* display status text and title */
message(ctrl.StatusText, str);
} |
The handler can be used to process events from Internet Explorer.
/* connect to Internet Explorer */
ie = createobject("internetexplorer.application");
/* navigate to home page */
ie.navigate("www.dadisp.com");
/* show it */
ie.visible = 1;
/* establish event handler */
registerevent(ie, "TitleChange", "MyEvent"); |
Each time the title displayed by Internet Explorer changes,
MyEvent
is called and a message box is displayed. The message box displays
the status line text and the current title of the displayed web
page.
Calculate Method
Calculate accepts a variable number of arguments from an ActiveX client.
Visual Basic Example:
Dim DADiSP as Object
Dim val as Variant
''' Connect to DADiSP
Set DADiSP = CreateObject("dadisp.application")
''' Create a 2 Window Worksheet without prompting
Call DADiSP.Execute("Newworksheet(2, 0)")
''' Generate 10x3 random array, return result as a variant
val = DADiSP.Calculate("rand", 10, 3) |
Starts DADiSP as an ActiveX Automation server, creates a 2 Window
Worksheet, returns a 10x3 random array by processing the input
arguments.
The placement of the arguments can be specified with the
$ character.
Visual Basic Example:
Dim DADiSP as Object
''' Connect to DADiSP
Set DADiSP = CreateObject("dadisp.application")
''' Create a 2 Window Worksheet without prompting
Call DADiSP.Execute("Newworksheet(2, 0)")
''' Generate a scaled 100 point random series with formula
Call DADiSP.Calculate("W1 := gnorm($1, 1)*$2", 100, 10) |
Starts DADiSP as an ActiveX Automation server, creates a 2 Window
Worksheet and places a 100 point random series in W1 scaled by 10
with a formula. The positions of the input arguments are specified
by the placeholder variables
$1 and
$2.