UNIBASE

REPEATING TEXT: How to Automate Text Duplication in Unibase

Unibase offers a powerful text preprocessing capability that extends beyond simple environment variable substitution. It allows for the efficient repetition of arbitrary text blocks, making the repeated content readily accessible to various Unibase components such as report formats, scripts, and dictionary entries. This repetition is controlled by a straightforward syntax, reminiscent of a ‘for loop’, enabling users to easily generate repetitive patterns with flexible indexing and incrementing options. The fundamental structure and usage of this text repetition feature are detailed below, along with illustrative examples.

This text preprocessing feature in Unibase is important for several reasons:

  • Efficiency and Reduced Redundancy: By allowing the repetition of text at a low level, Unibase avoids the need to manually duplicate the same content multiple times in different parts of a configuration or data structure. This leads to more concise and manageable files.
  • Consistency: When the same text needs to appear in multiple places (e.g., standard headers in reports, repeated instructions in scripts), using this feature ensures consistency across all instances. If the text needs to be updated, you only need to change it in one place.
  • Dynamic Content Generation: The inclusion of the repeat index (#) within the repeated text enables the generation of dynamic content. This allows for the creation of numbered lists, tables with sequential data, or any pattern where a repeating element needs to be differentiated by an index.
  • Flexibility and Control: The optional start and increment parameters provide fine-grained control over the repetition, allowing for counting forwards, backwards, or by specific intervals. This makes the feature adaptable to a wide range of text generation needs.
  • Simplified Syntax: The straightforward syntax makes it easy to define and implement text repetition without complex programming logic. This can save time and reduce the potential for errors.
  • Integration Across Unibase: Because the preprocessing happens at a low level, the benefits of text repetition are available throughout the Unibase system, enhancing the capabilities of reports, scripts, dictionary entries, and other components.

In essence, this feature streamlines the creation and maintenance of structured and repetitive text within Unibase, promoting efficiency, consistency, and dynamic content generation across the platform.

The syntax is simple:

{#<times>{:<start>{:<increment>}};,<text>}

where <times> is the limit of the repeat index.
<text> is the text to repeat (which may span several lines).
<start> is the starting index (optional – default 1)
<increment> is the increment per iteration (optional – default 1)
All three numbers can be negative. It works very much like a ‘for loop’ except the limit is the first number. This allows a simple repeat syntax where start and index are 1.

eg.

{#23, size #}
{#-5:-1:-1,count backwards # }

Inside <text> the character ‘#’ is replaced by the current repeat number.

eg.

{#5,some text #
}

would become

some text 1
some text 2
some text 3
some text 4
some text 5
Verified by MonsterInsights