Loop File Contents

Loops through the contents of the 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. Used to perform one or more actions on each item in a delimited text file.

Declaration

<AMLOOP TYPE="FILECONTENTS" FILE="text" RESULTVARIABLE="text" DELIMITER="text(options)">

See Also: Loop, End Loop, Loop Array, Loop Files, Loop Windows, Loop Expression, Loop Dataset, Loop List, Loop List Control, Loop Tree Control

To set Loop File Contents properties

  1. In the Available Actions pane, open the Loop folder and double-click the Loop File Contents action or drag it into the Steps pane.

  2. In the File box, click Open Folder and navigate to the file.

  3. In the Populate variable with file data box, select the variable to populate.

  4. In the Delimiter box, select the delimiter. If you select Custom, enter the delimiter in the Custom delimiter text box.

  5. To set the Description tab properties, refer to Description Tab Options.

  6. To set the Error Causes and On Error tab properties, refer to Step Error Handling.

  7. When finished, click OK to save settings and close the properties dialog box.

To auto-indent after all steps are added

  1. In the Steps pane, hold down SHIFT and click the first and last steps in the block so that the complete block of steps is selected.

  2. Click Format .

General Tab

Property

Type

Required

Default

Markup

Description

File

Text

Yes

While

FILE="C:\Temp\FileName.txt"

The file that contains the text to loop through.

Populate Variable with file data

Text

Yes

(Empty)

RESULTVARIABLE="varname"

The name of the variable that should be populated with the next delimited string on each successive loop.

Delimiter

Text (options)

No

New Line

DELIMITER="comma"

The character that delimits the text in the file. The available options are:

  • Comma: The delimiter is a comma (Example: item1,item2,item3).

  • New line: The delimiter is a new line (default).

  • Semi colon: The delimiter is a semi colon (Example: item1;item2;item3).

  • Space: The delimiter is a space (Example: item1 item2 item3).

  • Tabulation: The delimiter is a tab character.

  • Custom: The delimiter is another character as specified (enter the character in the provided text-box).

See Also

About Actions

Adding Task Steps

Loop Files Action