Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info

For the break functionality, let's say that you want to stop the iteration.

For the continue functionality, let's say that you want to skip to the next iteration.

Let's go to create the template.

How As you learned on the intermediate level how to use the set function, on this exercise we are going to put it into practice on the first line.

${set(count,0)}

And below it you put the #{for comments} or #{for <VariableName>=CommentsCount} statement.

Then you put the set function to count +1 because when entering the iteration sums +to sum 1 in to your count. After that, it calls the mapping that initialized on the set function.

${set(count,%{${count} + 1})}

Let's put the mappings that we want to print on the template.

Author

${Comments[n].AuthorFullName}
Body${Comments[n].Body}

Now, We are going to use the function continue with within a conditional block.

#{if (%{'${Comments[n].Body}'.equals('Hello Continue')})}

Jump the to next comment.

#{continue}

#{end}

When the comment is equal a to "Hello Continue", it is going to print the message "Jump the next comment" and the iteration goes to the start of the next iterationcomment.  

Info

We must have comments on your issue and a comment with "Hello Continue".

Below the code aboveAfter the conditional block with the continue statement, we are going to put a another conditional block that only print the message "Next comment", when the count of our set funciton is less than CommentsCount.

...

On the same template, we are going to learn the iteration statement break

Strating with the iteration #{for comments} or #{for <VariableName>=CommentsCount} statement.

...

#{if (%{'${Comments[n].Body}'.equals('Hello Stop')})}

Finish the iteration of comments.

#{break}

#{end}

When the comment is equal a to "Hello Stop", it is going to print the message "Finish the iteration of comments" and the iteration goes to stopstops, skipping to its end statement.

Info

We must have comments on your issue and a comment with "Hello Stop".

...

Below there is a sample of how the mappings will be displayed in a Word template:

Image RemovedImage Added

This template has:

...

Below there is a sample of how the generated file will be populated:

Image RemovedImage Added

Info

If you like this exercise, please share your opinion on the page by just leaving a comment or a (thumbs up). Your opinion is very important for us.

Thank you in advance.

Enjoy our product. (big grin)

...