Skip Method

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

Description

Use the Skip method to skip the given number of characters starting from the current position within a file.

Declaration

aqTextFileObj.Skip(SymbolsCount)

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

Applies To

The method is applied to the following object:

Parameters

The method has the following parameter:

SymbolsCount

Specifies the number of characters to skip.

If SymbolsCount is greater than 0, the cursor is moved forward (to the end of the file). If SymbolsCount is less than 0, then the cursor is moved backward (to the beginning of the file).

Result Value

True if the cursor position has changed by the given number of characters, and False otherwise.

If the number of characters remaining in the file is less than the number specified by the SymbolsCount parameter, then the method does nothing and returns False.

Example

The code below opens the specified file for both reading and writing, skips 8 letters and then posts the string from the current cursor position to the test log.

JavaScript, JScript

function SkipExample()
{
  var sPath = "D:\\Files\\MyFile.txt";
  
  // Opens the specified file for reading and writing
  var myFile = aqFile.OpenTextFile(sPath, aqFile.faReadWrite, aqFile.ctANSI);
  
  // Writes data to the file
  myFile.Write("Hello, world.");
  myFile.Write("One more line.");
  
  myFile.SetPosition(0, 0);
  
  myFile.Skip(7);
  var Str = myFile.ReadString(5);
  // Posts the current symbol to the test log
  Log.Message(Str);
    
  // Closes the file and saves the changes
  myFile.Close();
}

Python

def SkipExample():
  sPath = "D:\\Files\\MyFile.txt"
  # Opens the specified file for reading and writing
  myFile = aqFile.OpenTextFile(sPath, aqFile.faReadWrite, aqFile.ctANSI)
  # Writes data to the file
  myFile.Write("Hello, world.")
  myFile.Write("One more line.")
  myFile.SetPosition(0, 0)
  myFile.Skip(7)
  Str = myFile.ReadString(5)
  # Posts the current symbol to the test log
  Log.Message(Str)
  # Closes the file and saves the changes
  myFile.Close()

VBScript

Sub SkipExample

  sPath = "D:\Files\MyFile.txt"
  
  ' Opens the specified file for reading and writing
  Set myFile = aqFile.OpenTextFile(sPath, aqFile.faReadWrite, aqFile.ctANSI)
  
  ' Writes data to the file
  myFile.Write("Hello, world.")
  myFile.Write("One more line.")
  
  Call myFile.SetPosition(0, 0)
  
  myFile.Skip(7)
  Str = myFile.ReadString(5)
  ' Posts the current symbol to the test log
  Log.Message(Str)
    
  ' Closes the file and saves the changes
  myFile.Close
  
End Sub

DelphiScript

function SkipExample;
var sPath, myFile, Str;
begin
  sPath := 'D:\Files\MyFile.txt';
  
  // Opens the specified file for reading and writing
  myFile := aqFile.OpenTextFile(sPath, aqFile.faReadWrite, aqFile.ctANSI);
  
  // Writes data to the file
  myFile.Write('Hello, world.');
  myFile.Write('One more line.');
  
  myFile.SetPosition(0, 0);
  
  myFile.Skip(7);
  Str := myFile.ReadString(5);
  // Posts the current symbol to the test log
  Log.Message(Str);
    
  // Closes the file and saves the changes
  myFile.Close();
end;

C++Script, C#Script

function SkipExample()
{
  var sPath = "D:\\Files\\MyFile.txt";
  
  // Opens the specified file for reading and writing
  var myFile = aqFile["OpenTextFile"]( sPath, aqFile["faReadWrite"], aqFile["ctANSI"] );
  
  // Writes data to the file
  myFile["Write"]("Hello, world.");
  myFile["Write"]("One more line.");
  
  myFile["SetPosition"](0, 0);
  
  myFile["Skip"](7);
  var Str = myFile["ReadString"](5);
  // Posts the current symbol to the test log
  Log["Message"](Str);
    
  // Closes the file and saves the changes
  myFile["Close"]();
}

See Also

Working With Files From Scripts
SkipLine Method
SkipSpaces Method

Highlight search results