The mgiLoop Tag

Tag Behavior

Use the mgiLoop tag to repeat 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 no required parameters and seven optional parameters, a body and an ending tag. The tag forms are:

<mgiLoop first="Integer" last="Integer" step="Integer" 
indexName="Set Name">
Information to Repeat and &mgiLoopIndex;
</mgiLoop>

or

<mgiLoop item="Item" item="Item" indexName="Set Name">
Information to Repeat and &mgiLoopIndex;
</mgiLoop>

or

<mgiLoop itemList="List" indexName="Set Name" 
listDelimiter="Character">
Information to Repeat and &mgiLoopIndex;
</mgiLoop>

Required Parameters:

  • None

Optional Parameters:

  • indexName - The indexName 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.
  • first - The first is the first integer in the range of loop values.
  • last - The last is the last integer in the range of loop values.
  • step - The step 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.
  • item - The item is one item to be interated. Multiple item parameters may be included in one mgiLoop tag. Item parameters are looped in the order of the parameters in the mgiLoop tag.
  • itemList - The itemList is the list of values to loop. Each value in the item list is separated by the character specified by the listDelimiter parameter.
  • listDelimiter - The listDelimiter is the character that separates each value in the item list. To use escape characters such as carriage returns, line feeds, and tabs as delimiters use the appropriate Escaped String format. The default list delimiter is a comma.

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

Counting Loop

<mgiLoop 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 separate 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

Item Loop

<mgiLoop item="Dog" item="Cat" item="Rabbit" 
indexName="Animals">
<P>Is your favorite animal a &mgiLoopIndexAnimals;?</P>
</mgiLoop>

In this example, each of three items is placed in the sentence "Is your favorite animal a...?" 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.

Is your favorite animal a Dog?

Is your favorite animal a Cat?

Is your favorite animal a Rabbit?

List Loop

<mgiLoop 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.

Nested mgiLoop Tags

<mgiLoop first="1" last="3" indexName="Numbers">
<P>&mgiLoopIndexNumbers;.
<UL>
  <mgiLoop 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


[Understanding MGI Menu] [Using MGI Menu] [Referencing MGI Menu]


[MGI Guides Main Menu] [User Guide Main Menu]