DADiSP Worksheet Functions > Function Categories > ActiveX > Automation Client > RAISEEVENT

 

RAISEEVENT

Purpose:

Fires a user defined event with a variable number of arguments.

Syntax:

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.

Returns:

An integer, a value > 0 if successful.

Example:

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

 

Example:

Events fired by DADiSP can also be handled by DADiSP. Consider the following SPL event hander:

 

/* simple event handler */
MyEvent(argv)
{
    local i, str = "";
 
    loop (i = 1..argc)
    {
        str += sprintf("arg%d: %s ", i,
                       caststring(getargv(i)));
    }
    
    message("MyEvent", str);
}

 

By establishing an internal connection, the event can be fired and handled:

 

/* connect internally */
d = getobject();
 
/* establish SPL event handler for event 12 */
registerevent(d, 12, "MyEvent");
 
/* fire event */
raiseevent(12, "This is a test");

 

The SPL function MyEvent is called and displays the text:

 

 arg1: This is a test

Remarks:

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.

See Also:

CREATEOBJECT

FIREEVENT

GETCONTROL

GETOBJECT

REGISTEREVENT