Column Property

Applies to TestComplete 14.60, last modified on April 22, 2021

Description

Use the Column property to set or get the number of the current column, that is, the ordinal number of a character within a line. The number is zero-based.

Declaration

aqTextFileObj.Column

Read-Write Property Integer
aqTextFileObj An expression, variable or parameter that specifies a reference to an aqTextFile object

Applies To

The property is applied to the following object:

Property Value

A zero-based integer that indicates the number of the current column.

If the current column number cannot be determined (for example, when the cursor points to one of the first 3 bytes that indicate character encoding, or the cursor is placed within the newline character), the property returns -1.

Example

The code below obtains the first line of the specified file and posts this line by letters to the test log.

JavaScript, JScript

function ReadLine()
{
  
  var sPath = "D:\\Files\\MyFile.txt";
  
  // Opens the specified file for reading
  var myFile = aqFile.OpenTextFile(sPath, aqFile.faRead, aqFile.ctANSI);
  
  // Reads the first line and posts it by letters to the test log
  while (! myFile.IsEndOfLine() )
  {
    // Obtains the letter and its number
    var sLet = myFile.ReadString(1);
    var lNum = myFile.Column;
    Log.Message("The " + lNum + " letter is:");
    Log.Message(sLet);
  }
  
  // Closes the file
  myFile.Close();
}

Python

def ReadLine():
  sPath = "D:\\Files\\MyFile.txt"
  # Opens the specified file for reading
  myFile = aqFile.OpenTextFile(sPath, aqFile.faRead, aqFile.ctANSI)
  # Reads the first line and posts it by letters to the test log 
  while not myFile.IsEndOfLine():
    # Obtains the letter and its number
    sLet = myFile.ReadString(1)
    lNum = myFile.Column
    Log.Message("The " + str(lNum) + " letter is:")
    Log.Message(sLet)
  # Closes the file
  myFile.Close()

VBScript

Sub ReadLine
  
  sPath = "D:\Files\MyFile.txt"
  
  ' Opens the specified file for reading
  Set myFile = aqFile.OpenTextFile(sPath, aqFile.faRead, aqFile.ctANSI)
  
  ' Reads the first line and posts it by letters to the test log
  While Not myFile.IsEndOfLine
    ' Obtains the letter and its number
    sLet = myFile.ReadString(1)
    lNum = myFile.Column
    Log.Message("The " & lNum & " letter is:")
    Log.Message(sLet)
  WEnd
  
  ' Closes the file
  myFile.Close
  
End Sub

DelphiScript

function ReadLine;
var sPath, myFile, sLet, lNum;
begin
  
  sPath := 'D:\Files\MyFile.txt';
  
  // Opens the specified file for reading
  myFile := aqFile.OpenTextFile(sPath, aqFile.faRead, aqFile.ctANSI);
  
  // Reads the first line and posts it by letters to the test log
  while (not myFile.IsEndOfLine() ) do
  begin
    // Obtains the letter and its number
    sLet := myFile.ReadString(1);
    lNum := myFile.Column;
    Log.Message('The ' + IntToStr(lNum) + ' letter is:');
    Log.Message(sLet);
  end;
  
  // Closes the file
  myFile.Close();
end;

C++Script, C#Script

function ReadLine()
{
  
  var sPath = "D:\\Files\\MyFile.txt";
  
  // Opens the specified file for reading
  var myFile = aqFile["OpenTextFile"]( sPath, aqFile["faRead"], aqFile["ctANSI"] );
  
  // Reads the first line and posts it by letters to the test log
  while (! myFile["IsEndOfLine"]() )
  {
    // Obtains the letter and its number
    var sLet = myFile["ReadString"](1);
    var lNum = myFile["Column"];
    Log["Message"]("The " + lNum + " letter is:");
    Log["Message"](sLet);
  }
  
  // Closes the file
  myFile["Close"]();
}

See Also

Working With Files From Scripts
Line Property
Cursor Property
SetPosition Method

Highlight search results