LinkVariable Method
Applies To
AdvancedTcl Object
Prototype
LinkVariable(Interpreter As Long, VariableName As String, VariableType As Long, VariableAddress As Long, Flags As Long, Reserved As Long) As Long
Input
The "Interpreter" parameter, which must be a valid interpreter pointer. The "VariableName" parameter, which contains the name of the variable to link. The "VariableType" parameter, which specifies the desired variable link type for the specified variable. Please refer to the TCLBVariableLinkTypes page for the available variable link types. If the "VariableType" parameter is TCL_LINK_STRING, the "VariableAddress" parameter must be a handle returned from the SetStringValue method. The "VariableAddress" parameter, which contains the actual address (or handle in the case of the TCL_LINK_STRING type) of the variable. The "Flags" parameter, which is reserved for future use and must be zero. 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 or the "Interpreter" parameter is invalid.
E_NOTIMPL: The variable link type is not currently supported.
Side Effects
None.
Description
This method is a wrapper around the Tcl_LinkVar function. The native variable is directly linked to the Tcl variable; therefore, it is essential to supply a valid address for the variable.
Notes
None.
Example
Private Sub Command1_Click()
    Dim poTcl As TclBridge.AdvancedTcl
    Dim plInterpreter As Long
    Dim plData As Long
    Dim psOutput As String

    Set poTcl = New TclBridge.AdvancedTcl

    Call poTcl.CreateInterpreter(plInterpreter)

    Call poTcl.LinkVariable(plInterpreter, "TestVariable", TCLBVariableLinkTypes.TCL_LINK_INT, VarPtr(plData), 0&, 0&)

    Call poTcl.SetVariable(plInterpreter, "TestVariable", "1234", 0&, 0&)

    MsgBox "The data = " & plData, vbInformation, App.Title

    psOutput = vbNullString
    Call poTcl.GetVariable(plInterpreter, "TestVariable", psOutput, 0&, 0&)

    MsgBox "The variable = " & psOutput, vbInformation, App.Title

    Call poTcl.UnlinkVariable(plInterpreter, "TestVariable", 0&, 0&)

    Call poTcl.DeleteInterpreter(plInterpreter)

    Set poTcl = Nothing
End Sub