Syntax.CreateInvoke Method

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

The Syntax.CreateInvoke method creates and returns a syntax element that corresponds to any of the following expressions:

  • An expression containing a variable name, for example, MyVar.
  • An expression containing a routine call, for example, Eval(MyVar).
  • An expression containing an object’s property name, for example, Sys.Clipboard.
  • An expression containing an object’s method call, for example, Log.Message("Checkpoint passed.").

Using the properties of the returned InvokeSyntax object, you can specify the variable, routine, property or method to be invoked, the object that contains the desired property or method and, if needed, specify the parameter values to be passed to the invoked element.

Declaration

Syntax.CreateInvoke()

Result An InvokeSyntax object

Applies To

The method is applied to the following object:

Result Value

An InvokeSyntax object that corresponds to an invokation expression.

Example

The following code generates the Log.Message method call and displays the code in a message box:

JScript

function ShowMethodCallStatement()
{
    var oMethodCall = Syntax.CreateInvoke();
    oMethodCall.ClassValue = "Log";
    oMethodCall.InvokeName = "Message";
    oMethodCall.IsProperty = false;
    oMethodCall.AddParameter("Checkpoint passed.");

    var strCode = Syntax.GenerateSource(oMethodCall);
    aqDlg.ShowMessage(strCode);
}

VBScript

Sub ShowMethodCallStatement
    Dim oMethodCall, strCode

    Set oMethodCall = Syntax.CreateInvoke
    oMethodCall.ClassValue = "Log"
    oMethodCall.InvokeName = "Message"
    oMethodCall.IsProperty = False
    oMethodCall.AddParameter "Checkpoint passed."

    strCode = Syntax.GenerateSource(oMethodCall)
    aqDlg.ShowMessage strCode
End Sub

See Also

InvokeSyntax Object
CreateAssign Method
CreateCollection Method
CreateCondition Method
CreateIf Method
CreateVarDef Method
AddSyntaxToScript Method

Highlight search results