Text literals

Text literals define a character string in an expression.

Syntax 1 (using double quotes)

" char [...] "

Syntax 2 (using single quotes)

' char [...] '
  1. char is any character supported in the current locale, or a \ backslash escape character as described below:
    • \\ : the backslash character.
    • \" : double-quote character.
    • \' : single-quote character.
    • \n : newline character.
    • \r : carriage-return character.
    • \0 : null character.
    • \f : form-feed character.
    • \t : 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.

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

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

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 '  2 double quotes: " "   2 single quotes: '' \' '
displays as:
  2 double quotes: " "   2 single quotes: ' '
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 "  2 double quotes: "" \"   2 single quotes: ' ' "
displays as:
  2 double quotes: " "   2 single quotes: ' '
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"

The \xNN hexadecimal notation allows you to specify control characters in a string literal. Only ASCII codes (<=0x7F) are allowed.

MAIN
  DISPLAY "Some text in double quotes"
  DISPLAY 'Some text in single quotes'
  DISPLAY "Include double quotes:  \"  ""  "
  DISPLAY 'Include single quotes:  \'  ''  '
  DISPLAY 'Insert a newline character here: \n and continue with text.'
  DISPLAY "This is a text
     on multiple
     lines.\
     You can insert a newline with back-slash at the end of the line."
  IF "" IS NULL THEN
     DISPLAY 'Empty string is NULL'
  END IF
END MAIN