Increment Variable Icon Action

Increment Variable

Declaration

<AMINCREMENTVARIABLE RESULTVARIABLE="text (variable name)" AMOUNT="number" />

See Also

Create Array| Create Object | Create Variable | Define Type | ReDim Array | Return | Set Variable

Description

Increments a variable's value by the specified amount.  The variable must contain a valid number. If the variable's initial value is blank, zero is assumed. To decrease a variable's value, use the Decrement Variable action.

Practical Usage

Used to increase the value of a "counter" variable. Normally, counters are used inside of a loop.

Parameters

General Properties

Property

Type

Required

Default

Markup

Description

Variable to increment

Text

Yes

(Empty)

RESULTVARIABLE="thecurrentdate"

The name of the variable to increment.

Amount

Text

No

1

AMOUNT="5"

The value that the variable should be increased by.

Using Variables

All variables must be created before they can be used. This is done using the Create Variable action. Once created, variables can be set using the Set Variable action, or by certain actions that support populating variables. To get data out of the variables in any action parameter, simply surround the variable name with percentage % signs (i.e. %varname%). Remember not to use percentage signs when specifying the name of a variable to populate, percentage signs are only needed to get data out.

Description Properties

The Description tab allows you to customize the text description of any step as it appears in the Task Builder's Steps Pane.

More on setting custom step description

Error Causes Properties

The Error Causes tab properties lets you instruct a task step to react only to specific errors or ignore certain errors that should cause it to fail.

More on Error Causes properties

On Error Properties

The On Error tab properties lets you determine what the task should do if a particular step encounters an error as defined in the Error Causes properties.

More about On Error properties

Additional Notes

Expressions, Variables & Functions

A percent sign is used as a special character in AutoMate to indicate the beginning and end of an expression. This allows variables, functions and other expressions to be entered in any text parameter of a task's properties. For example: %1+1% inside a task will resolve to 2 at runtime. A more elaborate example is %FileDateTime(myFile)% which results to the date/time of myFile. To help construct expressions, you can open Expression Builder by clicking the Insert Expression (%) button or by pressing F2.

More on expressions

More on variables

More on functions

More on extended functions
More on the expression builder

Example

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

 

Description: This sample task Increments the specified variable's initial value of 0 by 10 during each loop.

 

<AMVARIABLE NAME="thecounter">0</AMVARIABLE>

<AMLOOP TOTALLOOPS="10">

     <AMINCREMENTVARIABLE RESULTVARIABLE="thecounter" AMOUNT="10" />

     <AMSHOWDIALOG WINDOWTITLE="CURRENT VALUE">Current Value is %thecounter%.</AMSHOWDIALOG>

</AMLOOP>

 

↑ Top of Page