Description
The ValueByName
property lets you obtain the value stored in the cell, which is specified by its column’s name.
Declaration
LogTableRowObj.ValueByName(ColumnName)
Read-Only Property | Variant |
LogTableRowObj | An expression, variable or parameter that specifies a reference to a LogTableRow object | |||
ColumnName | [in] | Required | String |
Applies To
The property is applied to the following object:
Parameters
The property has the following parameter:
Property Value
The value of the specified cell. It can be an integer or a floating-point number, a string, a boolean, a date-time value, a hyperlink or an image.
Note: | To determine the type of values in the given table column, you can use the LogColumn.DataType property. |
Remarks
To obtain the desired value, you can also use the Value
or ValueByIndex
property.
Example
The following example demonstrates how to obtain the value stored in the specified cell.
JavaScript, JScript
function TableDataRowSample()
{
var Logs, LogItem, LogData, DType, Row, Column, Value;
// Obtains a log item
Logs = Project.Logs;
LogItem = Logs.LogItem(0);
// Obtains the log item’s dataset
LogData = LogItem.Data(0);
DType = LogData.Scheme.DataType;
// Checks whether the dataset corresponds to the table
if (DType == 0)
{
// Obtains a table row by its index
Row = LogData.Rows(0);
// Obtains the value stored in the cell by the column name
Value = Row.ValueByName("Message");
// Posts the value to the test log
Log.Message(aqConvert.VarToStr(Value));
}
}
{
var Logs, LogItem, LogData, DType, Row, Column, Value;
// Obtains a log item
Logs = Project.Logs;
LogItem = Logs.LogItem(0);
// Obtains the log item’s dataset
LogData = LogItem.Data(0);
DType = LogData.Scheme.DataType;
// Checks whether the dataset corresponds to the table
if (DType == 0)
{
// Obtains a table row by its index
Row = LogData.Rows(0);
// Obtains the value stored in the cell by the column name
Value = Row.ValueByName("Message");
// Posts the value to the test log
Log.Message(aqConvert.VarToStr(Value));
}
}
Python
def TableDataRowSample():
# Obtains a log item
Logs = Project.Logs
LogItem = Logs.LogItem[0]
# Obtains the log item's dataset
LogData = LogItem.Data[0]
DType = LogData.Scheme.DataType
# Checks whether the dataset corresponds to the table
if DType == 0:
# Obtains a table row by its index
Row = LogData.Rows[0]
# Obtains the value stored in the cell by the column name
Value = Row.ValueByName["Message"]
# Posts the value to the test log
Log.Message(aqConvert.VarToStr(Value))
VBScript
Sub TableDataRowSample
' Obtains a log item
Set Logs = Project.Logs
Set LogItem = Logs.LogItem(0)
' Obtains the log item’s dataset
Set LogData = LogItem.Data(0)
DType = LogData.Scheme.DataType
' Checks whether the dataset corresponds to the table
If DType = 0 Then
' Obtains a table row by its index
Set Row = LogData.Rows(0)
' Obtains the value stored in the cell by the column name
Value = Row.ValueByName("Message")
' Posts the value to the test log
Log.Message(aqConvert.VarToStr(Value))
End If
End Sub
' Obtains a log item
Set Logs = Project.Logs
Set LogItem = Logs.LogItem(0)
' Obtains the log item’s dataset
Set LogData = LogItem.Data(0)
DType = LogData.Scheme.DataType
' Checks whether the dataset corresponds to the table
If DType = 0 Then
' Obtains a table row by its index
Set Row = LogData.Rows(0)
' Obtains the value stored in the cell by the column name
Value = Row.ValueByName("Message")
' Posts the value to the test log
Log.Message(aqConvert.VarToStr(Value))
End If
End Sub
DelphiScript
procedure TableDataRowSample();
var Logs, LogItem, LogData, DType, Row, Column, Value;
begin
// Obtains a log item
Logs := Project.Logs;
LogItem := Logs.LogItem[0];
// Obtains the log item’s dataset
LogData := LogItem.Data[0];
DType := LogData.Scheme.DataType;
// Checks whether the dataset corresponds to the table
if DType = 0 then
begin
// Obtains a table row by its index
Row := LogData.Rows[0];
// Obtains the value stored in the cell by the column name
Value := Row.ValueByName['Message'];
// Posts the value to the test log
Log.Message(aqConvert.VarToStr(Value));
end;
end;
var Logs, LogItem, LogData, DType, Row, Column, Value;
begin
// Obtains a log item
Logs := Project.Logs;
LogItem := Logs.LogItem[0];
// Obtains the log item’s dataset
LogData := LogItem.Data[0];
DType := LogData.Scheme.DataType;
// Checks whether the dataset corresponds to the table
if DType = 0 then
begin
// Obtains a table row by its index
Row := LogData.Rows[0];
// Obtains the value stored in the cell by the column name
Value := Row.ValueByName['Message'];
// Posts the value to the test log
Log.Message(aqConvert.VarToStr(Value));
end;
end;
C++Script, C#Script
function TableDataRowSample()
{
var Logs, LogItem, LogData, DType, Row, Column, Value;
// Obtains a log item
Logs = Project["Logs"];
LogItem = Logs.LogItem(0);
// Obtains the log item’s dataset
LogData = LogItem["Data"](0);
DType = LogData["Scheme"]["DataType"];
// Checks whether the dataset corresponds to the table
if (DType == 0)
{
// Obtains a table row by its index
Row = LogData["Rows"](0);
// Obtains the value stored in the cell by the column name
Value = Row["ValueByName"]("Message");
// Posts the value to the test log
Log["Message"](aqConvert["VarToStr"](Value));
}
}
{
var Logs, LogItem, LogData, DType, Row, Column, Value;
// Obtains a log item
Logs = Project["Logs"];
LogItem = Logs.LogItem(0);
// Obtains the log item’s dataset
LogData = LogItem["Data"](0);
DType = LogData["Scheme"]["DataType"];
// Checks whether the dataset corresponds to the table
if (DType == 0)
{
// Obtains a table row by its index
Row = LogData["Rows"](0);
// Obtains the value stored in the cell by the column name
Value = Row["ValueByName"]("Message");
// Posts the value to the test log
Log["Message"](aqConvert["VarToStr"](Value));
}
}
See Also
Access Test Log Contents from Tests
Value Property
ValueByIndex Property
LogColumn Object