CreateCommand Method
|
|
Applies To
|
BasicTcl Object, AdvancedTcl Object
|
Prototype
|
CreateCommand(Interpreter As Long, CommandName As String, CallbackObject As Object, MethodName As String, ClientData As Long, Reserved As Long) As Long
|
Input
|
The "Interpreter" parameter, which must be a valid interpreter pointer.
The "CommandName" parameter, which is the name of the new command to be added to the interpreter.
The "CallbackObject" parameter, which is the object responsible for handling the new command.
The "MethodName" parameter, which is the method responsible for handling the new command.
The "ClientData" parameter, which is user defined data to be passed into the method as a parameter when called by the interpreter.
The "Reserved" parameter, which is reserved for future use and must be zero.
|
Output
|
None.
|
Returns
|
Undefined.
|
COM Results
|
S_OK: Success.
E_INVALIDARG: Either a NULL pointer was passed, the "Interpreter" parameter is invalid, or the "CallbackObject" parameter is not a valid object. E_FAIL: An unexpected error was encountered. |
Side Effects
|
Upon success, a COM reference is added to the object specified in the "CallbackObject" parameter and a custom command is added to the specified interpreter.
|
Description
|
This method is a wrapper around the Tcl_CreateCommand function.
It creates the custom command in the specified interpreter and sets up the internal data necessary to call the specified object via the IDispatch interface.
When the interpreter attempts to call the command procedure, the component intercepts the call and performs the translation (non-trivial) and invokes the COM object.
|
Notes
|
None.
|
Example
|
Private Sub Command1_Click()
Dim poTcl As TclBridge.BasicTcl Dim poClass As Class1 Dim plInterpreter As Long Set poTcl = New TclBridge.BasicTcl Set poClass = New Class1 Call poTcl.CreateInterpreter(plInterpreter) Call poTcl.CreateCommand(plInterpreter, "Tester1", poClass, "Test1", 1234&, 0&) ' the EvaluateString method or the EvaluateFile method could be used here to test the new custom command... Call poTcl.DeleteCommand(plInterpreter, "Tester1") Call poTcl.DeleteInterpreter(plInterpreter) Set poClass = Nothing Set poTcl = Nothing End Sub |