RPTools

From MapToolDoc

while (roll option)

 This article is a stub, you can help the RPTools Wiki project by contributing content to expand this article.

Contents

WHILE Option

Introduced: Version 1.3.b46

Repeatedly executes a statement until a condition becomes false. The default separator is ",".

Usage

  1. [WHILE(condition): body]
  2. [WHILE(condition, separator): body]

Example

  1. [h:num = 10]
  2. [WHILE(num >= 0): num = num - 1]

Outputs 9,8,7,6,5,4,3,2,1

Example

This example demonstrates how to put multiple instructions inside a while loop using the CODE block extension.

Note the use of the second parameter to while to force a line break in the HTML output. Also notice that putting text on separate lines does NOT force the output on separate lines; the HTML br element is needed for that.

  1. [h: End = 5]
  2. [H: Num = 0]
  3. [WHILE(Num < End, "<br>"), CODE: {
  4.     Number is [Num = Num + 1],
  5.     Next will be [Num+1]
  6. }]

Outputs:

Number is 1, Next will be 2
Number is 2, Next will be 3
Number is 3, Next will be 4
Number is 4, Next will be 5
Number is 5, Next will be 6