SkipSpaces Method

Applies to TestComplete 15.69, last modified on November 13, 2024

Description

Use the SkipSpaces method to skip white spaces, tabulations, end of line characters and control characters and move the cursor position to the first meaningful character.

Declaration

aqTextFileObj.SkipSpaces()

aqTextFileObj An expression, variable or parameter that specifies a reference to an aqTextFile object
Result Boolean

Applies To

The method is applied to the following object:

Result Value

True if the cursor position has changed, and False otherwise.

Example

The code below opens the specified file for both reading and writing and adds some text to it. After that, the routine starts reading the file content, jumps over the leading spaces and posts the residual string to the test log.

JavaScript, JScript

function SkipSpacesExample()
{
  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.WriteLine(" Hello, world.");
    
  myFile.SetPosition(0, 0);
  
  myFile.SkipSpaces();
  var Str = myFile.ReadString(12);
  // Posts the current symbol to the test log
  Log.Message(Str);
    
  // Closes the file and saves the changes
  myFile.Close();
}

Python

def SkipSpacesExample():
  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.WriteLine(" Hello, world.")
  myFile.SetPosition(0, 0)
  myFile.SkipSpaces()
  Str = myFile.ReadString(12)
  # Posts the current symbol to the test log
  Log.Message(Str)
  # Closes the file and saves the changes
  myFile.Close()

VBScript

Sub SkipSpacesExample

  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.WriteLine(" Hello, world.")
    
  Call myFile.SetPosition(0, 0)
  
  myFile.SkipSpaces
  Str = myFile.ReadString(12)
  ' Posts the current symbol to the test log
  Log.Message(Str)
    
  ' Closes the file and saves the changes
  myFile.Close
  
End Sub

DelphiScript

function SkipSpacesExample;
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.WriteLine(' Hello, world.');
    
  myFile.SetPosition(0, 0);
  
  myFile.SkipSpaces();
  Str := myFile.ReadString(12);
  // 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 SkipSpacesExample()
{
  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["WriteLine"](" Hello, world.");
    
  myFile["SetPosition"](0, 0);
  
  myFile["SkipSpaces"]();
  var Str = myFile["ReadString"](12);
  // 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
Skip Method
SkipLine Method

Highlight search results