Windward DocumentationWindward DesignerDesigner for Microsoft OfficeFAQsHow Do I Use the ForEach Tag VarStatus Variables?

How Do I Use the ForEach Tag VarStatus Variables?

ForEach Tags provide special variables that can be used in other Tags and select statements. The varStatus variables give the user the means to refer to: the first row/node returned by a ForEach Tag; the last row/node returned by a ForEach Tag; the count of the current row/node returned by a ForEach Tag; and the index of the current row/node returned by a ForEach Tag.

VarStatus Variable Name

To use a ForEach Tag's varStatus variables, give them a name in the Properties Tab of your ForEach Tag. In this article we'll use "LoopStatus" as the name of the variables:

VarStatus Variable Syntax

In general, the syntax of the varStatus variables' names is the name of the variable with the varStatus name (set in Properties) prepended, e.g. "${LoopStatus.first}."

For example, in an Out Tag you could display the count of the current row/node returned by a containing ForEach Tag by referring to "${LoopStatus.count}."

varStatus Variable Description
count (${LoopStatus.count}) The number of rows/nodes actually returned by the ForEach Tag so far. This is one based and only counts rows/nodes actually returned - it is not effected by the begin and step ForEach Tag properties settings, unlike index (see below). For example, if begin is set to 3, then the count of the first row/node returned would still be 1.
first (${LoopStatus.first}) Returns true if the current row/node returned is the first row/node returned; otherwise returns false.
index (${LoopStatus.index}) The index of the current row/node returned by the ForEach Tag. This is zero based and identifies the current row/node based on the settings of the begin and step ForEach Tag properties. For example, if begin is set to 3, then the index of the first row/node returned would also be 3.
last (${LoopStatus.last}) Returns true if the current row/node returned is the last row/node that will be returned; otherwise returns false.

Example Template

For a demonstration of varStatus variables, please download and review this example template. It uses our public SQL Server data source, mssql.windward.net. It shows the effects of various settings of ForEach Tag begin and step properties settings on varStatus variables.