Loop File Contents Action

Declaration

<AMLOOP TYPE="FILECONTENTS" FILE="Text" RESULTVARIABLE="Text" DELIMITER="Text">

See Also

Loop File Contents Action-Setting Properties, Loop, End Loop, Loop Windows, Loop Processes, Loop Expression, Loop Dataset, Loop List, Break

Description

Loops through the contents of a specified text file and populates a variable with the current string of delimited text. The loop ends at the end of the file or if a Break step is encountered.

This action wraps the functionality of a Read from File action and a Loop List action into one concise loop structure.

Practical Usage

To perform an action on each item in a delimited text file.

Parameters

General Tab

File

Text, Required
MARKUP: FILE="C:\Temp\FileName.txt"

Specifies the file to loop.

Populate Variable with File Data

Text, Required
MARKUP: RESULTVARIABLE="varname"

Specifies an already created variable that should be populated with the next delimited string on each successive loop.

Delimiter

Text, Optional - Default: new line
MARKUP: DELIMITER="comma"

Specifies the character that delimits the items in the file.

The available options are:

Notes

Custom Description

This action includes the Description tab for entering a custom step description.

More on setting custom step description

Standard Error Handling Options

This action also includes the standard Error Causes and On Error failure handling options/tabs.

More on Error Handling Options

Variables and Expressions

All text fields allow the use of expressions, which can be entered by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, you can open Expression Builder from these fields by pressing F2.

More on variables
More on expressions

More on the expression builder

Example

NOTE: The code below can be copied and pasted directly into the Steps pane of the Task Builder.

<AMLOOP TYPE="FILECONTENTS" FILE="C:\Temp\FileName.txt" RESULTVARIABLE="VariableName" DELIMITER="|">