Variable - Decrement
Declaration
<AMVARIABLE ACTIVITY="decrement" RESULTVARIABLE="text" AMOUNT="number" />
Overview
Decrements the value of a variable by the specified amount. The variable must contain a valid whole number. If the variable's initial value is blank, zero is assumed.
Practical usage
Used to decrease the value of a counter variable. Normally, counters are used inside of a loop. To increment a variable value, use the Increment variable activity.
Parameters
General
| Property | Type | Required | Default | Markup | Description |
|---|---|---|---|---|---|
| Variable to decrement | Text | Yes | (Empty) | RESULTVARIABLE="theNumber" | The name of the variable containing the value to decrement. The variable must contain a valid number. If the variable initial value is blank, zero is the number assumed. |
| Decrement by | Text | No | 1 | AMOUNT="5" | Decreases the variable value by the value entered. |
Additional notes
Using variables
All variables must be created before they can be used. This is done using the Create variable activity. Once created, variables can be set using the Set variable activity, or by certain actions that support populating variables. To extract data from the variables in any action parameter, enclose the variable name with percent signs (%) (for example, %varname%). Do not use percent signs when specifying the name of a variable to populate, they are only needed to extract data.
Example
- Copy and paste the sample AML code below directly into the Task Builder Steps Panel.
- To successfully run the sample code, update parameters containing user credentials, files, file paths, or other information specific to the task to match your environment.
Description
The following sample task decrements the initial specified variable value of 100 by 20 during each loop.
<AMVARIABLE NAME="thecounter" VALUE="100"></AMVARIABLE>
<AMLOOP TOTALLOOPS="5"><AMDECREMENTVARIABLE RESULTVARIABLE="thecounter" AMOUNT="20" /><AMSHOWDIALOG WINDOWTITLE="CURRENT VALUE">%thecounter%</AMSHOWDIALOG></AMLOOP>
<AMVARIABLE ACTIVITY="decrement" RESULTVARIABLE="thecounter" AMOUNT="20" />
<AMSHOWDIALOG WINDOWTITLE="CURRENT VALUE">%thecounter%</AMSHOWDIALOG>
<AMLOOP ACTIVITY="end" />