do while loop example in X++ Programming Language

Rumman Ansari   Software Engineer   2023-08-27   7803 Share
☰ Table of Contents

Table of Content:


Syntax


do {
   // Loop body;
   Statement(s);
} while (loop-continuation-condition);

Example

The given code is an example of a do-while loop in X++ programming language. It declares an integer variable n and initializes it to 0.

The do-while loop in X++ is a loop statement that executes a block of statements repeatedly until the specified condition becomes false. In this case, the loop block contains a call to the info function which prints the value of n along with the string "Number " to the infolog.

In each iteration of the loop, the value of n is incremented by 1 until it reaches 10. Once n becomes equal to or greater than 10, the condition n < 10 becomes false and the loop terminates.

Therefore, this code will print the numbers from 0 to 9 to the infolog window.


// do while loop example

static void Examples(Args _args)
{ 
	int n = 0;

	do{
			info(strFmt("Number %1",n));
			n++;
	} while(n < 10);
}