Reformat Report


The code splits a block of text into lines of my maximum specified length. This can be useful when forwarding a report to a downstream system that requires it to be formatted using shorter lines of text.

If you have any questions please contact us at

Using the Code [top]

  • Import the Reformat Report channel from the Builtin: Iguana Tools repository
  • Experiment with the code to find out how it works
  • Then add the module to your Translator project
  • Copy the require statement from the channel and add it at the top of your script
    Note: This module uses require to return a single function
  • Adapt the code to your own requirements
  • Use string.formatText()  to split a block of text into lines with a specified max length
  • Interactive scripting help is included for this module

This is the github code for the main module:

How it works [top]

First we count the number of lines in the report as it is originally formatted. We do this by splitting it into a table of individual lines (using the string.split() function), then we count the number of rows in the table.

Then we reformat the report into lines of shorter length as specified by MAXLENGTH using the string.formatText() function. Then we concatenate the table into a single string using table.concat(). And finally we count the number of lines in the new report, in the same way as we did for the original.

More information [top]


Leave A Comment?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.