Loop - File Contents

Declaration

<AMLOOP ACTIVITY="filecontents" FILE="text" 
RESULTVARIABLE="text" ENCODING="text 
(options)" DELIMITER="text (options)">

Description: 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.

Practical Usage

Used to perform one or more activities on each delimited item in a text file. This activity wraps the functionality of a Read from file and a Loop list activity into one concise loop structure.

General Parameters

Property

Type

Required

Default

Markup

Description

File

Text

Yes

While

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

The path and filename of the file that contains the data to loop through.

Populate variable with file data

Text

Yes

(Empty)

RESULTVARIABLE="varname"

The name of an existing variable to populate with the next delimited string on each successive loop.

Encoding

Text (options)

No

ANSI

  1. ENCODING="ansi"

  2. ENCODING="unicode"

  3. ENCODING="unicodebigendian"

  4. ENCODING="utf-8"

The character encoding system to use. Proper encoding may be required to facilitate the transmission of data through telecommunication networks or for storage purposes on non-Windows operating systems. The available options are:

  • ANSI (default) - The standard for the core fonts supplied with US versions of Microsoft Windows.

  • Unicode - Industry standard for the consistent encoding, representation and handling of text expressed in most of the world's writing systems.

  • Unicode big endian - Architecture in which, within a given 16- or 32-bit word, bytes at lower addresses have lower significance (the word is stored ‘little-end-first’).

  • UTF-8 - Variable-width encoding that can represent every character in the Unicode character set. It was designed for backward compatibility with ASCII.

Delimiter

Text (options)

No

New Line

  1. DELIMITER="comma"

  2. DELIMITER="new_line"

  3. DELIMITER="semi-colon"

  4. DELIMITER="space"

  5. DELIMITER="tab"

The character used to separate each string of text to loop through. The available options are:

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

  • New line (default) - 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 a user-defined character. Enter the desired character in the provided text-box.

Description tab - A custom description can be provided on the Description tab to convey additional information or share special notes about a task step.

Error Causes tab - Specify how this step should behave upon the occurrence of an error. (Refer to Task Builder > Error Causes Tab for details.)

On Error tab - Specify what AWE should do if this step encounters an error as defined on the Error Causes tab. (Refer to Task Builder > On Error Tab for details.)

Example

The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.

This task uses a Write to File activity to write the text "This is the space delimited text." to C:\Temp\theSampleFile.txt. A Loop File Contents activity then reads the space delimited contents of that file and displays each in a message box.

<AMVARIABLE NAME="mycounter">1</AMVARIABLE>
<AMLOOP TYPE="EXPRESSION" EXPRESSION="mycounter=5" CONDITION="until">
<AMSHOWDIALOG MESSAGE="%mycounter%" />
<AMINCREMENTVARIABLE RESULTVARIABLE="mycounter" />
<AMLOOP>