WriteBlankLines Method

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

Description

Use the WriteBlankLines method to insert (starting from the current cursor position) a number of line breaks in a text file.

Declaration

aqTextFileObj.WriteBlankLines(LinesCount)

aqTextFileObj An expression, variable or parameter that specifies a reference to an aqTextFile object
LinesCount [in]    Required    Integer    
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

LinesCount

Specifies a number of blank lines to be inserted.

Result Value

True if the write operation has completed successfully, and False otherwise.

Example

The code below opens the specified file for writing, adds some data to it and then closes the file saving the changes.

JavaScript, JScript

function WriteBlankLinesToFile()
{
  var sPath = "D:\\Files\\MyFile.txt";
  
  // Opens the specified file for writing
  var myFile = aqFile.OpenTextFile(sPath, aqFile.faWrite, aqFile.ctANSI);
  
  // Writes data to the file
  myFile.WriteLine("Line 1");
  myFile.WriteBlankLines(1);
  myFile.WriteLine("Line 2");
  myFile.WriteBlankLines(2);
  myFile.WriteLine("Line 3");
  
  // Closes the file and saves the changes
  myFile.Close();
}

Python

def WriteBlankLinesToFile():
  sPath = "D:\\Files\\MyFile.txt"
  # Opens the specified file for writing
  myFile = aqFile.OpenTextFile(sPath, aqFile.faWrite, aqFile.ctANSI)
  # Writes data to the file
  myFile.WriteLine("Line 1")
  myFile.WriteBlankLines(1)
  myFile.WriteLine("Line 2")
  myFile.WriteBlankLines(2)
  myFile.WriteLine("Line 3")
  # Closes the file and saves the changes
  myFile.Close()

VBScript

Sub WriteBlankLinesToFile

  sPath = "D:\Files\MyFile.txt"
  
  ' Opens the specified file for writing
  Set myFile = aqFile.OpenTextFile(sPath, aqFile.faWrite, aqFile.ctANSI)
  
  ' Writes data to the file
  myFile.WriteLine("Line 1")
  myFile.WriteBlankLines(1)
  myFile.WriteLine("Line 2")
  myFile.WriteBlankLines(2)
  myFile.WriteLine("Line 3")
  
  ' Closes the file and saves the changes
  myFile.Close
  
End Sub

DelphiScript

function WriteBlankLinesToFile;
var sPath, myFile;
begin  sPath := 'D:\Files\MyFile.txt';
  
  // Opens the specified file for writing
  myFile := aqFile.OpenTextFile(sPath, aqFile.faWrite, aqFile.ctANSI);
  
  // Writes data to the file
  myFile.WriteLine('Line 1');
  myFile.WriteBlankLines(1);
  myFile.WriteLine('Line 2');
  myFile.WriteBlankLines(2);
  myFile.WriteLine('Line 3');
  
  // Closes the file and saves the changes
  myFile.Close();
end;

C++Script, C#Script

function WriteBlankLinesToFile()
{
  var sPath = "D:\\Files\\MyFile.txt";
  
  // Opens the specified file for writing
  var myFile = aqFile["OpenTextFile"]( sPath, aqFile["faWrite"], aqFile["ctANSI"] );
  
  // Writes data to the file
  myFile["WriteLine"]("Line 1");
  myFile["WriteBlankLines"](1);
  myFile["WriteLine"]("Line 2");
  myFile["WriteBlankLines"](2);
  myFile["WriteLine"]("Line 3");
  
  // Closes the file and saves the changes
  myFile["Close"]();
}

See Also

Working With Files From Scripts
LinesCount Property
WriteLine Method

Highlight search results