The mgiLoop Tag

Tag Behavior

The mgiLoop tag repeats an action or display for a specified range of numbers or a specified list of values.


Tag Syntax

The mgiLoop tag has a beginning tag with one required parameter and one optional parameter, a body, and an ending tag. In addition, the mgiLoop tag has required and optional parameters for specific modes. The tag form is:

<mgiLoop mode="Mode" indexName="Set Name">
&mgiLoopIndexIndexName;
</mgiLoop>

Required Parameters:

  • mode="Mode" where "Mode" is the current behavior of the mgiLoop tag. Valid modes include "Counting" and "List". See the specific required and optional parameters for each mode below.
    • Counting - The counting mode repeats an action or display for a specified range of numbers using a specified interval. (2 required, 1 optional parameter)
    • List - The list mode repeats an action or display for a specified list of values. (2 required parameters).

Optional Parameters:

  • indexName="Set Name" where "Set Name" is the name of the range of numbers or list of values in the mgiLoop tag. The index name is appended to the loop index marker (&mgiLoopIndex;) before the semi-colon to refer to a specific set of loop values when mgiLoop tags are nested.

Counting Mode Required Parameters:

  • first="Number" where "Number" is the first integer in the range of loop values. If the first number is greater than the last number, the mgiLoop tag will automatically loop in descending order (from largest to smallest).
  • last="Number" where "Number" is the last integer in the range of loop values.

Counting Mode Optional Parameters:

  • step="Number" where "Number" is an integer that represents the loop interval from the first number to the last number in the range. For example, a step of "2" will loop every other number in the range beginning with the first number. The default step is "1" which loops every number in the range.

List Mode Required Parameters:

  • itemList="Values" where "Values" is the list of values to loop. Each value in the item list is separated by the character specified by the listDelimiter parameter.
  • listDelimiter="Delimiter" where "Delimiter" is the character that separates each value in the item list. For example, the following item list of colors is de-limited by commas:

red, orange, yellow, green, blue, violet

The Loop Index Marker:

  • &mgiLoopIndex; - the loop index marker is the location of the number or list value during each loop. The index name (indexName) is appended to the loop index marker (before the semi-colon) to refer to a specific set of loop values when mgiLoop tags are nested. For example, to refer to the index name "Colors", the loop index marker would be the following:

&mgiLoopIndexColors;


Example Usage and Output

Example Counting Mode Usage and Output

<mgiLoop mode="Counting" first="1" last="10" step="2">
&mgiLoopIndex; <BR>
</mgiLoop>

In this example, every other number (beginning with the first number) between 1 and 10 is displayed on a seaprate line as follows. If values are not separated by an HTML tag such as a header tag, paragraph tag or break tag then they are displayed continuously on one line.

1
3
5
7
9

Example List Mode Usage and Output

<mgiLoop mode="List" itemList="Red,Orange,Yellow,Green,Blue" 
listDelimiter="," indexName="Colors">
<P>&mgiLoopIndexColors; is a color in the rainbow.</P>
</mgiLoop>

In this example, each item in the set of colors is placed in the sentence "Value is a color in the rainbow." and displayed as follows. If values are not separated by an HTML tag such as a header tag, paragraph tag or break tag then they are displayed continuously on one line.

Red is a color in the rainbow.

Orange is a color in the rainbow.

Yellow is a color in the rainbow.

Green is a color in the rainbow.

Blue is a color in the rainbow.

Example Nested mgiLoop Tags Usage and Output

<mgiLoop mode="Counting" first="1" last="3" indexName="Numbers">
<P>&mgiLoopIndexNumbers;.
<UL>
  <mgiLoop mode="List" itemList="A,B,C" listDelimiter="," indexName="Letters"> 
  <LI>&mgiLoopIndexLetters;
  </mgiLoop>
</UL>
</mgiLoop>

When you nest mgiLoop tags, you must use the "indexName" parameter and include the indexName parameter value in the loop index marker (otherwise the index loop marker may not display the values from the appropriate itemlist). In this example, an outline is created nesting a loop of the letters A, B and C in a bullet list inside a loop that counts from 1 to 3. The outline would appear as:

1

  • A
  • B
  • C

2

  • A
  • B
  • C

3

  • A
  • B
  • C


Suggested Usage

  • Repeating actions
  • Form Processing


[Return to the Referencing MGI Menu]


[User Guide Main Menu] [Understanding MGI Menu] [Using MGI Menu] [Referencing MGI Menu]