Escape Sequences In String Constants

Benchmark Description Language permits the use of escape sequences (for example, \, \n, \t, \n) in formatting string constants. The valid escape sequences match those in the programming language C and extend this set with the hexadecimal sequence \h. The meaning of the escape sequences are as follows:

Escape sequence Description
\ line continuation
\n new line, line feed
\r carriage return
\t tabulator
\v vertical tab
\b backspace
\a bell alert
\f new page, form feed
\\ backslash
\" double quote
\h hexadecimal representation
\x next character in hexadecimal representation

Example: \x2A indicates an asterisk

Example

dcltrans
  transaction TString
  var
    sString1, sString2: string;
  begin
    sString1 := "This is a constant string"
                "split into two lines"
    sString2 := "This is the first line, \
                 this is still the first line\nThis is the second line";
    write(sString1); writeln; write(sString2); writeln;
  end TString;

Example

const
  cbuf1 := "\h4142434A" // "ABCJ" length = 4
           "\h204142434A20" // " ABCJ " length = 6
           "\x20b\x20c\x20d"; // " b c d" length = 6
  // "ABCJ ABCJ b c d" length = 16

dcltrans
  transaction TMain
  const
    c1 := "abc";
  var
    s1 : string;
    n1 : number;
  begin
    s1 := "abc"
          "def";
    s1 := cbuf1;
    n1 := sizeof(cbuf1); 
    write("length=" + string(n1)); writeln;
    write("\h4142434A" // "ABCJ" length = 4
          "\h204142434A20" // " ABCJ " length = 6
          "a\x20\x20b\x20c\x20d" // "a b c d" length = 8
    // "ABCJ ABCJ a b c d" length = 18);
    writeln;
    write("length=" + string(sizeof(
          "\h4142434A" // "ABCJ" length = 4
          "\h204142434A20" // " ABCJ " length = 6
          "a\x20\x20b\x20c\x20d") // "a b c d" length = 8
    // "ABCJ ABCJ a b c d" length = 18
    ));
    writeln;
    end TMain;

Output

length=16
ABCJ ABCJ a b c d 
length=18