XenoGuard 4.0 Documentation

Replace Content

ActionStep Reference » Windows » File » Replace Content 

The ActionStep File Replace Content changes all occurrences of a specified string in a file.


[-] Hide
  1. Open the Windows node in the Workspace Explorer.
  2. Open the File node, select the Replace Content ActionStep.

Parameters:

The ActionStep has the following input parameters:


name Description
Path Name
The path name of the file where content is to be replaced.

Allowed Context Scopes [Fixed, Local, Global]
Allowed Context Types [Variable, Parameter, Enum]
Encoding
Specifies the character encoding used for the content.

Available character encoding schemes: ASCII, ANSI, UTF-8, UTF-8-BOM, Unicode

Allowed Context Scopes [Fixed, Local, Global]
Allowed Context Types [Variable, Parameter, Enum]
Replacements
The content list replaces the Search String placeholder with the Replace String placeholder.

Allowed Context Scopes [Fixed, Local, Global]
Allowed Context Types [Variable, Parameter]

Results:

The ActionStep returns the following results:


name
description
Number of Replacements
The total number of replaced strings in the file.

Allowed Context Scopes [Fixed, Local, Global]
Allowed Context Types 
[Variable, Parameter]

Example 1 (Replace all the string prefixes of web pages in a file):

This example reads the content of a file and changes all occurrences of a specified string value, "www." with another string value, "https://". The count on how many replacements were made is stored in Number of Replacements and output via Write Text.

Example 2 (Update content of a .cpp file):

This example creates two local variables, SearchString and ReplaceString, with Text as data types. The variables are then used to search and replace the content of a .cpp file. If the content has been successfully replaced, the file content is read and a notice that the file was updated with the number of replacements done on the file is displayed via Message Box.


See other File operations: