If an action or decision node has an exit transition with a guard as well as a second exit transition, and there is also a transition that brings the flow back to the original decision point, IBM® Rational Rhapsody recognizes that these elements represent a while loop, and generates the appropriate code.
Generation of for loops in flowchart code
If an action or decision node has an exit transition with a guard as well as a second exit transition, and there is also a transition that brings the flow back to the original decision point, you can have Rational Rhapsody generate a for loop rather than a while loop by carrying out the following steps.
Open the Features window for the action or decision that has the guard for exiting the loop, and apply the stereotype FlowChartForLoop to the element.
After setting the stereotype for the element, enter the relevant loop initialization code in the Loop initialization field on the General tab of the Features window.
Enter the relevant loop increment code in the Loop step field on the General tab of the Features window.
For example, the following flowchart segment will result in a for loop, as can be seen in the generated code that follows it. In this example, the code used for Loop initialization was monthCounter = 1, and the code used for Loop step was monthCounter++