---
title: "Exercise 1 - Break or Continue Statement"
canonical: "https://docs.getxporter.app/space/XPORTERCLOUD/559469/Exercise%201%20-%20Break%20or%20Continue%20Statement"
format: markdown
---
> Macro (rw-ui-expands-macro)
> 
> > Macro (rw-expand)
> 
> > Macro (toc)

# Introduction

In this exercise, <span style="color: #0d0d0d">you'll learn how to use the Break or Continue statement within an </span>[<span style="color: #0d0d0d">Xporter Template</span>](https://docs.getxporter.app/space/XPORTERCLOUD/427622)<span style="color: #0d0d0d"> to control </span>[<span style="color: #0d0d0d">Iterations</span>](https://docs.getxporter.app/space/XPORTERCLOUD/428318)<span style="color: #0d0d0d">.</span>

> ℹ️ - For the Break functionality, you'll halt the iteration when a certain condition is met.
> ℹ️ - For the Continue functionality, you'll skip to the next iteration if a condition is fulfilled.

# Iterating with the BREAK or CONTINUE Statement

> Macro (rw-ui-steps-macro)
> 
> > Macro (rw-step)
> 
> Create the template.
> 
> > Macro (rw-step)
> 
> Utilize the Set function, as learned in the [intermediate level](https://docs.getxporter.app/space/XPORTERCLOUD/428075), to initialize the variable *count* to 0:
> 
> ```
> ${set(count,0)}
> ```
> 
> > Macro (rw-step)
> 
> Below it, include the <span style="color: #0d0d0d">iteration </span><span style="color: #0d0d0d">statement, either</span> `#{for comments}` or `#{for <VariableName>=CommentsCount}`
> 
> > Macro (rw-step)
> 
> Use the Set function to *count +1* when entering the Iteration to *sum 1* to your count. At every Iteration the value of *count *will be `count + 1`
> 
> ```
> ${set(count,%{${count} + 1})}
> ```
> 
> > Macro (rw-step)
> 
> Include the [mappings](https://docs.getxporter.app/space/XPORTERCLOUD/558575) you want to print on the Template, such as *Author* and *Body*.
> 
> | **Mapping** | **Description** |
> | --- | --- |
> | Author | ${Comments[n].AuthorFullName} |
> | Body | ${Comments[n].Body} |
> 
> > Macro (rw-step)
> 
> Implement the Continue function within a [Conditional Block](https://docs.getxporter.app/space/XPORTERCLOUD/527146).
> 
> ```
> #{if (%{'${Comments[n].Body}'.equals('Hello Continue')})}
> 
> Jump to next comment.
> 
> #{continue}
> 
> #{end}
> ```
> 
> > Macro (rw-step)
> 
> When a comment matches *"Hello Continue"*, <span style="color: #0d0d0d">the message "Jump to the next comment" is printed, and the Iteration proceeds to the next comment.</span>
> 
> > ℹ️ You must have comments on your Issue, and a comment with "Hello Continue".
> 
> > Macro (rw-step)
> 
> After the Conditional Block with the Continue statement, add another Conditional Block to print the message "Next comment" only when the count is less than *CommentsCount*:
> 
> ```
> #{if (%{'${count}' < '${CommentsCount}'})}
> 
> Next comment.
> 
> #{end}
> ```
> 
> > Macro (rw-step)
> 
> Close the Iteration comments with `#{end}`
> 
> > Macro (rw-step)
> 
> <span style="color: #0d0d0d">Implement the Break statement within the same Template.</span>
> 
> > Macro (rw-step)
> 
> Start with the `#{for comments}` or `#{for <VariableName>=CommentsCount}` Iteration statement.
> 
> > Macro (rw-step)
> 
> Include the mappings you want to print on the template, such as *Author* and *Body*.
> 
> |  |  |
> | --- | --- |
> | Author | ${Comments[n].AuthorFullName} |
> | Body | ${Comments[n].Body} |
> 
> > Macro (rw-step)
> 
> Use the Break function with a Conditional Block:
> 
> ```
> #{if (%{'${Comments[n].Body}'.equals('Hello Stop')})}
> 
> Finish the iteration of comments.
> 
> #{break}
> 
> #{end}
> ```
> 
> > Macro (rw-step)
> 
> When a comment matches "Hello Stop," the message "Finish the iteration of comments" is printed, and the Iteration stops.
> 
> > ℹ️ You must have comments on your issue and a comment with "**Hello Stop**".
> 
> > Macro (rw-step)
> 
> Close the Iteration comments with `#{end}`
> 
> ## Examples
> 
> Below (Figure 1) there is a sample of how the mappings will be displayed in a Word template.
> 
> ![Figure 1 - Word template](media://bf79cfc7-fbe9-49ff-8a15-bea44b97f9df)
> 
> This Template (Figure 1) includes:
> 
> - A header with a logo (Figure 1 - 1).
> - Headings (Figure 1 - 2).
> - Text styling (Figure 1 - 3).
> 
> Below (Figure 2 and 3) there are two samples of how the generated file will be populated.
> 
> ![Figure 2 - Populated file](media://0f8ba907-4a76-4a33-bc2d-36cfd3af589f)
> 
> ![Figure 3 - Populated file](media://31ace4aa-a4a6-4568-b7c2-3901f8954464)


> ℹ️ **This exercise is now complete. Proceed to **[**Exercise 2**](https://docs.getxporter.app/space/XPORTERCLOUD/528151)** to learn h****ow to populate the time tracking with some issues with pivot tables.**
> ℹ️ 
> ℹ️ If you like this exercise, please share your opinion on the page by just leaving a comment or a 👍. Your opinion is very important to us.
> ℹ️ 
> ℹ️ Thank you in advance. Enjoy our product!

<details>
<summary>Exercise 1 Resources</summary>

| **File** | **Description** |
| --- | --- |
|  | Exercise 1 - Sample template file |
|  | Exercise 1 - Sample generated file |
</details>


<details>
<summary>Support/Troubleshooting</summary>

If you have questions or technical issues, please [contact the Support team via the Customer Portal (Jira service management)](https://jira.getxray.app/servicedesk/customer/portal/2/user/login?destination=portal%2F2%2Fcreate%2F28) or [send us a message using the in-app chat](https://docs.getxporter.app/space/XPORTERCLOUD/18251779/In-App+Chat+Support).
</details>