Text literals

Text literals define a character string in an expression.

Syntax 1: Using double quote delimiters

" char [...] "

Syntax 2: Using single quote delimiters

' char [...] '

Syntax 3: Using the % localized string marker

%" char [...] "
  1. In all above syntaxes, char can be any character supported in the current locale.
  2. Syntax 3 defines a localized string.
  3. The char can be a \ backslash escape combination as described in the following table:
    Table 1. String literal escape sequences
    Escape sequence Description
    \\ The backslash character
    \" double-quote character (to be used with double quote delimiters)
    \' single-quote character (to be used with single quote delimiters)
    \n The newline character
    \r The carriage-return character
    \0 The null character
    \f The form-feed character
    \t The tab character
    \xNN ASCII character defined by the hexadecimal code NN

Usage

A text literal (or character string literal) defines a character string constant containing valid characters in the current application character set.

The application character set is defined by the current locale.

An empty string ("") is equivalent to NULL.

A text literal can be written on multiple lines, the compiler merges lines by removing the newline character.

The escape character is the backslash character (\).

When using single quotes as delimiters, double quotes can be used as is inside the string, while single quotes must be doubled or escaped with a backslash:
DISPLAY ' " "  '' \' '      -- shows:  " "  ' '
When using double quotes as delimiters, single quotes can be used as is inside the string, while double quotes must be doubled or escaped with a backslash:
DISPLAY " "" \"  ' ' "      -- shows:  " "  ' '
With single or double quote delimiters, special characters can be specified with backslash escape symbols. Use for example \n to insert a new-line character in a string literal:
DISPLAY "First line\nSecond line"
When using single or double quotes and the string literal is written on multiple lines, the string pieces are concatenated:
DISPLAY "piece1
 piece2
 piece3" -- shows:    piece1 piece2 piece3
With single and double quote delimiters, the \xNN hexadecimal notation allows you to specify control characters in a string literal. Only ASCII codes (<=0x7F) are allowed:
DISPLAY "\x65"    -- shows:   e
DISPLAY `\x65`    -- shows:   \x65
When prefixing the string with a % percent sign, you specify the key for a localized string. This key will be replaced at runtime by another text, found in string resource files:
MESSAGE %"orders.message.shipped"
For more details, see Localized strings

Example

MAIN
  
  DISPLAY "Some text in double quotes"
  DISPLAY 'Some text in single quotes'

  DISPLAY "  \"  ""  "
  DISPLAY '  \'  ''  '

  DISPLAY 'Newline character here:\n ... and continue on next line.'

  DISPLAY "This is a double quoted string
 on multiple lines, that
 will show concatenated."

  DISPLAY ( "" IS NULL )
  DISPLAY ( '' IS NULL )

END MAIN
Output:
Some text in double quotes
Some text in single quotes
Some text in back quotes
  "  "  
  '  '  
Newline character here:
 ... and continue on next line.
This is a double quoted string on multiple lines, that will show concatenated.
     1
     1
     1