fn: do-while
[contents]

Contents

Syntax

The syntax for do-while loops is:

f++:  
do-while{options}(condition)
{
	//loop code-block
}

n++:  
@do-while{options}(condition)
{
	//loop code-block
}

Note: Single-line code blocks do not need to be enclosed in parentheses.

Description

The do-while function takes a single parameter specifying a loop condition, then loops through the code-block following the call while the loop condition does not evaluate to 0 (for do-while loops the loop condition is evaluated after each iteration of the loop code-block).

Note: f++ is used for do-while conditions, even for n++. If you accidentally use n++ for the condition it will most often run without any syntax or semantic errors anyway.

Note: If not writing to the output file Nift will skip to the first non-whitespace (ie. to the first character that is not a space, tab or newline) after a do-while loop and inject it to the output file where the call started. If you want to prevent Nift from doing this put a '!' after the loop, eg.:

@do-while{!o}(condition)
{
	# block
}!

Options

The following options are available for do-while loops:

option description
f++ parse do-while loop code-block with f++
n++ parse do-while loop code-block with n++
!o do not add output
s add scope
!s do not add scope
!\n do not add newline between each loop iteration
\n add double newline between each loop iteration
eob="value" add value between each loop iteration
option description

f++ example

Examples of do-while being used with f++:

int i=0
do-while(i < 10)
	console("i: `i+=1`")

int i=0
do-while{!s, !o}(i+=1; i<10)
	console("i: ", i)

n++ example

Examples of do-while being used with n++:

@int i=0
@do-while{\n}(i < 10)
	i:  @++(i)

@int i=0
@do-while{f++, !o, !s}(i+=1; i<10)
{
	//f++ code for scripting
}