company logo

ASCII Templates

OSI templates can be considered as inverse OSI functions, but there are some restrictions compared with OSI functions. In order to distinguish code from text, for inserting comments and for other reasons, some characters have been reserved and have to be used with care when appearing in the text.

One may create any sort of text output using template functions. The only reserved characters in a template are $ and \. When template text contains $ or \, one needs to add a \ before, i.e. \$ or \\ in the text will be converted to $ or \ respectively .

Fill characters

Blanks, new lines (0x0D0A or 0x0A) and tabs (0x09) are considered as fill characters. In some cases, fill characters are not displayed properly. Usually, all fill characters between text and embedded expressions are considered as part of the text constant.

This will also include a blank between first and family name (see example 1). Line breaks or tabs between embedded expressions or at the beginning of the text are also considered as fill characters to be displayed in the result (example 2).

For ignoring line breaks between embedded expressions one may use the line connector \. Adding a "\" at the end of a line causes the template to consider the next line as continuation of the current line. This also allows inserting line breaks in the template text, which may increase the readability of the template (example 3).

// template text 1

  ...

  $responsible(0).first_name$ $responsible(0).second_name$

  ...

// --> generated OSI code

  WriteResult(responsible(0).first_name,false);

  WriteResult(" ",false);  

  WriteResult(responsible(0).second_name,false);

// template text 2

  ...

  $responsible(0).first_name$

  $responsible(0).second_name$

  ...

// --> generated OSI text

  WriteResult(responsible(0).first_name,false);

  WriteResult("\n",false);  

  WriteResult(responsible(0).second_name,false);

// template text 3

  ...

  This is a longer text constant to be displayed in the result \

  in a single line. To make the template more readable, we can \

  add "\\" in the template text before line break.

  ...

Fill character sequences

All new lines found in the template before and after text constants are considered as text constants and included in the result. Thus, the template fragment

One may also add explicitly defined fill characters as \n, \t or \, which will have the same effect. In order to write characters as \n to the output, control characters have to be escaped by double backslash.

// Example 1: fixed text in template

  You will get an response during the next three days.

  ...

// will generate the following OSI function code

  WriteResult("You will get an response during the next three days. \n...\n",false);

// example 2: explicit control characters

  You will get an response during the next three days.\n...\n

// will generate the same code as the example above

  WriteResult("You will get an response during the next three days. \n...\n",false);

// example 3: write control sequences to output  

  You will get an response during the next three days.\\n...\\n

// will generate the following OSI function code

  WriteResult("You will get an response during the next three days. \\n...\\n",false);

Comments

Comments are line comments introduced by //. Comments can be placed at the end of a line, only, i.e. any text after the comment-begin is considered as part of the comment until the line end.

Comments within a text constant are not recognized as such but considered as part of the text constant. Adding comments in a template is possible at the beginning of the template or after embedded code or immediately after a fill character sequence (example 1)

In order to append a comment at the end of a text constant, you have to insert an explicit line break before the comment (example 2). For generating // sequences as template text, one may use \/, which will be converted to // (example 3)

Example 1

  // this is a valid line comment (at beginning of template)

  This is part of the template text // and this also

  $Data$      // display current data - valid comment

Example 2

  This is part of the template text \n// after line end this becomes a comment

  $Data$    // display current data - valid comment

Example 3

  This is part of the template text \/ generated as //

  $Data$    // display current data - valid comment