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 |
|
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:
|
Delimiter |
Text (options) |
No |
New Line |
|
The character used to separate each string of text to loop through. The available options are:
|
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>