while (roll option): Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 14: Line 14:
====Example====
====Example====
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h:num=10]
[h:num = 10]
[WHILE(num>=0): num = num-1]
[WHILE(num >= 0): num = num - 1]
</source>
</source>
Outputs ''9,8,7,6,5,4,3,2,1''
Outputs ''9,8,7,6,5,4,3,2,1''
Line 21: Line 21:
====Example====
====Example====
<source lang="mtmacro" line>
<source lang="mtmacro" line>
[h: End=10]
[h: End = 10]
[H: Num=0]
[H: Num = 0]
[WHILE(Num<End), CODE: {[Num = Num + 1]}]
[WHILE(Num < End), CODE: {[Num = Num + 1]}]
</source>
</source>
Outputs ''1, 2, 3, 4, 5, 6, 7, 8, 9, 10''
Outputs ''1, 2, 3, 4, 5, 6, 7, 8, 9, 10''

Revision as of 23:35, 29 June 2009

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

WHILE Option

Introduced: Version 1.3.b46

Repeatedly executes a statement until a condition becomes false.

Usage

[WHILE(condition): body]
[WHILE(condition, separator): body]

Example

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

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

Example

[h: End = 10]
[H: Num = 0]
[WHILE(Num < End), CODE: {[Num = Num + 1]}]

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