Syntax.CreateAssign Method

Applies to TestComplete 14.0, last modified on January 23, 2019

Description

This method creates and returns a syntax element that corresponds to an assignment statement, for example:

JavaScript, JScript

Answer = 42;

Python

Answer = 42;

VBScript

Answer = 42

DelphiScript

Answer := 42;

C++Script, C#Script

Answer = 42;

To specify the left and right parts of the assignment operator, use the Left and Right properties of the AssignSyntax object returned by the Syntax.CreateAssign method.

Declaration

Syntax.CreateAssign()

Result An AssignSyntax object

Applies To

The method is applied to the following object:

Result Value

An AssignSyntax object that corresponds to an assignment statement.

Example

The following example generates the assignment statement given in the Description section and displays it in a message box:

JScript

function ShowAssignmentStatement ()
{
  var oVarName = Syntax.CreateInvoke();
  oVarName.InvokeName = "Answer";
  oVarName.IsProperty = true;

  var oAssignment = Syntax.CreateAssign();
  oAssignment.Left = oVarName;
  oAssignment.Right = 42;

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

VBScript

Sub ShowAssignmentStatement
  Dim oVarName, oAssignment, strCode

  Set oVarName = Syntax.CreateInvoke
  oVarName.InvokeName = "Answer"
  oVarName.IsProperty = True

  Set oAssignment = Syntax.CreateAssign
  oAssignment.Left = oVarName
  oAssignment.Right = 42

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

See Also

AssignSyntax Object
Syntax.CreateCollection Method
Syntax.CreateCondition Method
Syntax.CreateInvoke Method
Syntax.CreateIf Method
Syntax.CreateVarDef Method
Recorder.AddSyntaxToScript Method

Highlight search results