BasicNoUIObjCreateHandler Method |
Create an object that can invoke a module sub or function.
Namespace: WinWrap.Basic.ServerAssembly: WinWrap.Basic.Server (in WinWrap.Basic.Server.dll)
Syntaxpublic Handler? CreateHandler(
string prototype
)
Public Function CreateHandler (
prototype As String
) As Handler
public:
virtual Handler^ CreateHandler(
String^ prototype
) sealed
Parameters
- prototype String
-
This string value is the prototype of the sub or function that will be
handled.
A module specific Handler's prototype string must begin with
"modulepath|", such as, "mymodule.bas|Sub DoIt()".
User defined type parameters are NOT allowed.
If modulepath is a null string,
FileName is used.
(The string "|..." is the same as prefixing the string with FileName.)
Parameter modifiers like ByVal, ByRef, Optional, ParamArray and ()
for arrays are allowed.
Return Value
Handler
A
Handler object.
If
prototype is invalid null (
Nothing for Visual Basic)
is returned.
Implements
IBasicNoUICreateHandler(String)
Remarks
The IDE shows the
Handler in the object/proc drop down lists.
This method must be called BEFORE the target code is loaded.
Macro/Module Paths
Macro/module paths are typically file paths.
However, it is sometimes useful to work with macros/modules that are not
stored as files.
A macro/module path is of the form:
Part
|
Description
|
---|
'*'
|
Paths that being with '*' are non-file system macro/modules.
The application provides the methods for reading and writing these files.
Paths that begin and end with '*' are hidden from the IDE.
User's can't step into or otherwise inspect the contents.
|
'**'
|
Paths that begin with '**' are non-file system modules.
The application provides the methods for reading and writing these files.
Running an event-driven module loads it using LoadModule.
|
path
|
This is the identity of the macro/module.
|
Example
Call a script based handler:
private Handler onKeyHandler;
private void Form1_Load(object sender, System.EventArgs e)
{
onKeyHandler = basicIdeCtl1.CreateHandler("Sub OnKey(KeyAscii As KeyEventArgs)");
}
private void Form1_Closed(object sender, System.Windows.Forms.FormClosedEventArgs e)
{
if (onKeyHandler != null)
onKeyHandler.Dispose();
}
private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
try
{
onKeyHandler.Call(e);
}
catch (TerminatedException e1)
{
}
catch (Exception e2)
{
onKeyHandler.ReportError(e2);
}
}
Private OnKeyHandler As Handler
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
OnKeyHandler = BasicIdeCtl1.CreateHandler("Sub OnKey(KeyAscii As KeyEventArgs)")
End Sub
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
If OnKeyHandler IsNot Nothing Then OnKeyHandler.Dispose()
End Sub
Private Sub textBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles textBox1.KeyPress
Try
OnKeyHandler.Call(e)
Catch e1 As TerminatedException
' ignore this error
Catch e2 As Exception
OnKeyHandler.ReportError(e2)
End Try
private: Handler ^ onKeyHandler;
private: System::Void Form1_Load(System::Object ^ sender, System::EventArgs ^ e)
{
onKeyHandler = basicIdeCtl1->CreateHandler(L"Sub OnKey(KeyAscii As KeyEventArgs)");
}
private: System::Void Form1_Closed(System::Object ^ sender, System::Windows::Forms::FormClosedEventArgs ^ e)
{
if (onKeyHandler != NULL)
onKeyHandler->Dispose();
}
private: void textBox1_KeyDown(Object ^ sender, System::Windows::Forms::KeyEventArgs ^ e)
{
try
{
onKeyHandler->Call(e);
}
catch (TerminatedException ^ e1)
{
}
catch (Exception ^ e2)
{
onKeyHandler->ReportError(e2);
}
}
See Also