for (roll option)

From RPTools Wiki
Revision as of 00:14, 20 April 2009 by Lindharin (talk | contribs)
Jump to navigation Jump to search

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

FOR Option

Introduced: Version 1.3.b46

Executes a statement for a number of iterations based on a start and end value.

Usage

[FOR(var, start, end): body]
[FOR(var, start, end, stepsize): body]
[FOR(var, start, end, stepsize, separator): body]

The var variable counts from start towards end during the loop, and the optional stepsize (default +1) is added to var at each iteration. Note that in the standard incrementing usage with a stepsize of 1, the body does not execute when var reaches end.

Example

[FOR(i,0,10): "i is now " + i]

Counts up from 0 to 9.

[FOR(i,10,0,-2): "i is now " + i]

Counts down even numbers from 10 to 0.

Version Changes

  • 1.3b54 - Changed the third parameter from the end value to a count value. In b53 and earlier, on each iteration it compared if var less than or equal to end to determine whether to continue executing the body. As of b54, it is now comparing if var less than end, so the body will never see a value of var equal to end.