Log.CreateNewAttributes Method

Applies to TestComplete 15.63, last modified on April 23, 2024

Description

The CreateNewAttributes method creates a new LogAttributes object, which defines font and color settings. Later, you can pass this object as the Attr parameter to the Log.CreateFolder, Log.Error, Log.Warning, Log.Message, Log.Event, Log.Picture, Log.File and Log.Link methods in order to apply the settings defined by the object to the test log folders and messages respectively. Once the object is created, its properties are populated with default font and color settings. So, if you pass this object to the mentioned methods as is, without changing its properties, this will act as if you omitted the Attr parameter of these methods.

Declaration

Log.CreateNewAttributes()

Result A LogAttributes object

Applies To

The method is applied to the following object:

Result Value

A LogAttributes object that represents font and color settings.

Example

The code below creates a new LogAttributes object and then passes this object as a parameter to the Log.Message method.

JavaScript, JScript

function CorrectRGBComponent(component)
{
  component = aqConvert.VarToInt(component);
  if (component < 0)
    component = 0;
  else
    if (component > 255)
      component = 255;
  return component;
}

function RGB(r, g, b)
{
  r = CorrectRGBComponent(r);
  g = CorrectRGBComponent(g);
  b = CorrectRGBComponent(b);
  return r | (g << 8) | (b << 16);
}

function Test()

{
  var Attr;
  Attr = Log.CreateNewAttributes();
  Attr.FontColor = RGB(192, 0, 0);
  Attr.BackColor = RGB(255, 255, 0);
  
  // Passes the LogAttributes object to the Message function
  Log.Message("My message", "", pmNormal, Attr);
}

Python

def CorrectRGBComponent(component):
  component = aqConvert.VarToInt(component)
  if component < 0:
    component = 0
  else: 
    if component > 255:
      component = 255
  return component

def RGB(r, g, b):
  r = CorrectRGBComponent(r)
  g = CorrectRGBComponent(g)
  b = CorrectRGBComponent(b)
  return r | (g << 8) | (b << 16)

def Test():
  Attr = Log.CreateNewAttributes()
  Attr.FontColor = RGB(192, 0, 0)
  Attr.BackColor = RGB(255, 255, 0)
  # Passes the LogAttributes object to the Message function
  Log.Message("My message", "", pmNormal, Attr)

VBScript

Sub CorrectRGBComponent(ByRef component)
  component = aqConvert.VarToInt(component)
  If (component < 0) Then
    component = 0
  Else
    If (component > 255) Then
      component = 255
    End If
  End If
End Sub

Function RGB(r, g, b)
  Call CorrectRGBComponent(r)
  Call CorrectRGBComponent(g)
  Call CorrectRGBComponent(b)
  RGB = r + (g * 256) + (b * 65536)
End Function

Sub Test
  Set Attr = Log.CreateNewAttributes
  Attr.FontColor = RGB(192, 0, 0)
  Attr.BackColor = RGB(255, 255, 0)
  
  ' Passes the LogAttributes object to the Message function
  Log.Message "My message", "", pmNormal, Attr
End Sub

DelphiScript

procedure CorrectRGBComponent(var component);
begin
  component := aqConvert.VarToInt(component);
  if (component < 0) then
    component := 0
  else
    if (component > 255) then
      component := 255;
end;

function RGB(r, g, b) : integer;
begin
  CorrectRGBComponent(r);
  CorrectRGBComponent(g);
  CorrectRGBComponent(b);
  Result := r or (g shl 8) or (b shl 16);
end;

procedure Test;
var Attr : OleVariant;
begin
  Attr := Log.CreateNewAttributes;
  Attr.FontColor := RGB(192, 0, 0);
  Attr.BackColor := RGB(255, 255, 0);
  
  // Passes the LogAttributes object to the Message function
  Log.Message('My message', '', pmNormal, Attr);
end;

C++Script, C#Script

function CorrectRGBComponent(component)
{
  component = aqConvert["VarToInt"](component);
  if (component < 0)
    component = 0;
  else
    if (component > 255)
      component = 255;
  return component;
}

function RGB(r, g, b)
{
  r = CorrectRGBComponent(r);
  g = CorrectRGBComponent(g);
  b = CorrectRGBComponent(b);
  return r | (g << 8) | (b << 16);
}

function Test()
{
  var Attr;
  Attr = Log["CreateNewAttributes"]();
  Attr["FontColor"] = RGB(192, 0, 0);
  Attr["BackColor"] = RGB(255, 255, 0);
  
  // Passes the LogAttributes object to the Message function
  Log["Message"]("My message", "", pmNormal, Attr);
}

See Also

Test Results
CreateFolder Method
Error Method
Warning Method
Message Method
Event Method
File Method
Link Method
LogAttributes Object

Highlight search results