GetVariableType Method

Applies to TestComplete 12.60, last modified on September 17, 2018

Description

This method returns the string corresponding to the variable type. This is the value shown in the Type column of the Variables page.

Declaration

VariablesObj.GetVariableType(Variable)

VariablesObj An expression, variable or parameter that specifies a reference to a Variables object
Variable [in]    Required    Variant    
Result String

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

Variable

Either the variable's unique name or its index within the variables collection. The index is zero-based, so the first variable has index 0, the second - 1 and so on.

Result Value

One of the following strings:

Value Description
Boolean The variable holds boolean values.
Double The variable holds floating-point values and dates.
Integer The variable holds integer values.
Object The variable holds object references.
String The variable holds string values.
Password The variable holds encrypted string values.
Table The variable holds a two-dimensional table of values (a scripting interface to a table variable is provided by the TableVariable object).
DB Table
(note the space between the words)
The variable can be linked to an external data source, such as a database table or recordset, an Excel spreadsheet or CSV file, and returns values from that source (a scripting interface to a database table variable is provided by the DBTableVariable object).

Remarks

If a variables collection does not contain the specified variable, an error occurs.

Example

The following code snippet obtains project suite variables and posts their properties to the test log.

JavaScript, JScript

function Variables()
{

  var Variables, Count, VarName;

  // Obtains a list of project suite variables
  Variables = ProjectSuite.Variables;
  // Obtains the total number of variables in the project suite
  Count = Variables.VariableCount;

  // Iterates through the project suite variables
  for (var i = 0; i < Count; i++)
    {
    // Obtains a variable's name and posts it to the test log
    VarName = Variables.GetVariableName(i);
    Log.AppendFolder(VarName);

    // Posts the variable’s category to the test log
    Log.Message("Category: " + Variables.GetVariableCategory(i));
    // Posts the variable’s type to the test log
    Log.Message("Type: " + Variables.GetVariableType(i));
    // Posts the variable’s default value to the test log
    Log.Message("Default Value: " + Variables.GetVariableDefaultValue(i));
    // Posts the variable’s description to the test log
    Log.Message("Description: " + Variables.GetVariableDescription(i));

    Log.PopLogFolder();
    }

}

Python

def Variables():

  # Obtains a list of project suite variables
  Variables = ProjectSuite.Variables
  # Obtains the total number of variables in the project suite
  Count = Variables.VariableCount

  # Iterates through the project suite variables
  for i in range (0, Count):
    # Obtains a variable's name and posts it to the test log
    VarName = Variables.GetVariableName(i)
    Log.AppendFolder(VarName)

    # Posts the variable's category to the test log
    Log.Message("Category: " + str(Variables.GetVariableCategory(i)))
    # Posts the variable's type to the test log
    Log.Message("Type: " + str(Variables.GetVariableType(i)))
    # Posts the variable's default value to the test log
    Log.Message("Default Value: " + str(Variables.GetVariableDefaultValue(i)))
    # Posts the variable's description to the test log
    Log.Message("Description: " + str(Variables.GetVariableDescription(i)))

    Log.PopLogFolder()

VBScript

Sub Variables

  Dim Variables, Count, VarName

  ' Obtains a list of project suite variables
  Set Variables = ProjectSuite.Variables
  ' Obtains the total number of variables in the project suite
  Count = Variables.VariableCount

  ' Iterates through the project suite variables
  For i = 0 To Count - 1
    ' Obtains a variable's name and posts it to the test log
    VarName = Variables.GetVariableName(i)
    Log.AppendFolder(VarName)

    ' Posts the variable’s category to the test log
    Log.Message("Category: " & Variables.GetVariableCategory(i))
    ' Posts the variable’s type to the test log
    Log.Message("Type: " & Variables.GetVariableType(i))
    ' Posts the variable’s default value to the test log
    Log.Message("Default Value: " & Variables.GetVariableDefaultValue(i))
    ' Posts the variable’s description to the test log
    Log.Message("Description: " & Variables.GetVariableDescription(i))

    Log.PopLogFolder
  Next

End Sub

DelphiScript

procedure Variables();
var Variables, Count, VarName, i;

begin

  // Obtains a list of project suite variables
  Variables := ProjectSuite.Variables;
  // Obtains the total number of variables in the project suite
  Count := Variables.VariableCount;

  // Iterates through the project suite variables
  for i := 0 to Count - 1 do
    begin
    // Obtains a variable's name and posts it to the test log
    VarName := Variables.GetVariableName(i);
    Log.AppendFolder(VarName);

    // Posts the variable’s category to the test log
    Log.Message('Category: ' + Variables.GetVariableCategory(i));
    // Posts the variable’s type to the test log
    Log.Message('Type: ' + Variables.GetVariableType(i));
    // Posts the variable’s default value to the test log
    Log.Message('Default Value: ' + aqConvert.VarToStr(Variables.GetVariableDefaultValue(i)));
    // Posts the variable’s description to the test log
    Log.Message('Description: ' + Variables.GetVariableDescription(i));

    Log.PopLogFolder;
    end;

end;

C++Script, C#Script

function Variables()
{

  var Variables, Count, VarName;

  // Obtains a list of project suite variables
  Variables = ProjectSuite["Variables"];
  // Obtains the total number of variables in the project suite
  Count = Variables["VariableCount"];

  // Iterates through the project suite variables
  for (var i = 0; i < Count; i++)
    {
    // Obtains a variable's name and posts it to the test log
    VarName = Variables["GetVariableName"](i);
    Log["AppendFolder"](VarName);

    // Posts the variable’s category to the test log
    Log["Message"]("Category: " + Variables.GetVariableCategory(i));
    // Posts the variable’s type to the test log
    Log["Message"]("Type: " + Variables.GetVariableType(i));
    // Posts the variable’s default value to the test log
    Log["Message"]("Default Value: " + Variables.GetVariableDefaultValue(i));
    // Posts the variable’s description to the test log
    Log["Message"]("Description: " + Variables.GetVariableDescription(i));

    Log["PopLogFolder"]();
    }

}

See Also

GetVariableCategory Method
GetVariableDescription Method
GetVariableName Method

Highlight search results