Read File Action Icon

Read File Action

Declaration

<AMFILEREAD FILE="text" RESULTVARIABLE="text" MAXBYTES="number" BYTESVARIABLE="text">

See Also

Copy File, Move File, Delete File, Delete Folder, Rename Folder

Description

Reads data from a file and places the data in a variable.

Practical Usage

To read data from a text file. For example, a user may wish to read a list of names from a text file and use that data with the Send Keystrokes action to send the data to another action. To do this, start with the Read File Action to put all the data into a variable, then use the Loop List action to loop through the data, inside the loop use the Send Keystrokes action.

Parameters

General Tab

File
Text, Required
MARKUP: FILE="c:\sourcefoldername\file.txt"

Specifies the file(s) to containing the data that should be read.

Populate Variable with Data
Text, Required
MARKUP: RESULTVARIABLE="varname"

Specified the name of the variable to populate with the text contents of the file. The variable must have been created using a Create Variable <AMCREATEVAR> previous step.

Populate Variable with Number of Bytes Read
Text, Required
MARKUP: BYTESVARIABLE="varname"

Specified the name of the variable to populate with the number of bytes that were read from the file. The variable must have been created using a Create Variable <AMCREATEVAR> previous step.

Max. Number of Characters to Read
number, Optional default - (5120)
MARKUP: MAXBYTES="7777"

The maximum number of bytes that should be read from the text file. This limit is important because it prevents AutoMate from taking up a virtually unlimited amount of system memory depending on the size of the file. Text beyond this amount of space is truncated.

Notes

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 by surrounding the expression in percentage signs (example: %MYVARIABLE%, %Left('Text',2)%). To help construct these expressions, a popup expression builder is available in all these fields by pressing F2.
More on variables...
More on expressions...
More on the expression builder...

Example

<AMFILEREAD FILE="C:\foldername\names.txt" RESULTVARIABLE="datafromfile" MAXBYTES="100000" BYTESVARIABLE="amountread">