DADiSP Worksheet Functions > Function Categories > ActiveX > Automation Client > RAISEEVENT
Fires a user defined event with a variable number of arguments.
RAISEEVENT(eventID, arg1, arg2, …, argN)
eventID |
- |
An integer, the event number, a value between 9 and 16. |
argN |
- |
Any value. Zero or more values to pass to the event handler. |
An integer, a value > 0 if successful.
The following is an example of an event handler in C#. The project connects to the DADiSP automation server and establishes an event handler for the DADiSP EventID 10. RAISEEVENT invokes the C# handler.
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private DADiSP.DADiSPApp DADiSP;
public Form1()
{
InitializeComponent();
// connect to DADiSP Automation Server
DADiSP = new DADiSP.DADiSPApp();
// delegate for DADiSP Event 10
DADiSP.Event10 += new DADiSP.IDadispEvents_Event10EventHandler(DADiSP_Event10);
// show it
DADiSP.Visible = 1;
}
// event handler for generic event 10 fired by DADiSP
private void DADiSP_Event10(System.Array e)
{
String s = "", caption = "DADiSP Event 10";
// zero or more args
for (int i = 0; i < e.GetLength(0); i++)
{
s += e.GetValue(i) + " ";
}
MessageBox.Show(s, caption);
}
}
}
In DADiSP, the statement:
raiseevent(10)
causes the DSP_Event10 C# code to execute and display a message box. No arguments are passed to the handler.
The DADiSP statement:
raiseevent(10, "MyText", 3, 6.5)
causes the DSP_Event10 handler to be called with an array of three arguments. The C# handler displays a message box with the text:
MyText 3 6.5
Events fired by DADiSP can also be handled by DADiSP. Consider the following SPL event hander:
By establishing an internal connection, the event can be fired and handled:
The SPL function MyEvent is called and displays the text:
arg1: This is a test
RAISEEVENT passes any type and number of arguments as a SafeArray of Variants suitable for .NET languages.
RAISEEVENT supports eight events with EventID numbers 9 through 16.
See FIREEVENT to fire an event with a variable number of arguments passed as a Variant array suitable for most script and automation languages such as VBA.
The following internal events are fired automatically:
Event Name |
EventID |
Arguments |
Description |
DataChanged |
100 |
String bstrIn |
Window value has changed, bstrIn contains the Window name |
EvaluationCompleted |
101 |
String bstrIn |
Window evaluation has completed, bstrIn contains the Window name |
NumWindowsChanged |
102 |
None |
Windows added or removed from a Worksheet |
WorksheetLoaded |
103 |
String bstrIn |
A Worksheet was loaded, bstrIn contains the Worksheet name |
FormulaChanged |
104 |
String bstrIn |
Window formula has changed, bstrIn contains the Window name |
LogText |
200 |
String bstrIn |
Text added to the logfile, bstrIn contains the new text |
StatusText |
201 |
String bstrIn |
Status line message, bstrIn contains the message text |
ErrorText |
202 |
String bstrIn |
Error message, bstrIn contains the error text. |