Operator $ (Non-Escaped String Literal)
Explicitly indicates that a string literal should not be processed for escape sequences.
$"text"
$
This operator explicitly indicates that the string literal following it (wrapped in double quotes) should not be processed for escape sequences. This a preprocessor operator and can only be used with string literals at compile time.
The default behavior for string literals is that they not be processed for escape sequences. However, Option Escape in the -lang fblite dialect can be used to override this default behaviour causing all strings to be processed for escape sequences.
Use the ! Operator (Escaped String Literal) to explicitly indicate that a string should be processed for escape sequences.
Syntax
$"text"
Parameters
$
The preprocessor non-escaped operator
"text" The string literal
Description
This operator explicitly indicates that the string literal following it (wrapped in double quotes) should not be processed for escape sequences. This a preprocessor operator and can only be used with string literals at compile time.
The default behavior for string literals is that they not be processed for escape sequences. However, Option Escape in the -lang fblite dialect can be used to override this default behaviour causing all strings to be processed for escape sequences.
Use the ! Operator (Escaped String Literal) to explicitly indicate that a string should be processed for escape sequences.
Example
'' Compile with -lang fblite or qb
#lang "fblite"
Print "Default"
Print "Backslash : \\"
Print !"Backslash !: \\"
Print $"Backslash $: \\"
Print
Option Escape
Print "Option Escape"
Print "Backslash : \\"
Print !"Backslash !: \\"
Print $"Backslash $: \\"
Print
'' OUTPUT:
'' Default
'' Backslash : \\
'' Backslash !: \
'' Backslash $: \\
'' Option Escape
'' Backslash : \
'' Backslash !: \
'' Backslash $: \\
#lang "fblite"
Print "Default"
Print "Backslash : \\"
Print !"Backslash !: \\"
Print $"Backslash $: \\"
Option Escape
Print "Option Escape"
Print "Backslash : \\"
Print !"Backslash !: \\"
Print $"Backslash $: \\"
'' OUTPUT:
'' Default
'' Backslash : \\
'' Backslash !: \
'' Backslash $: \\
'' Option Escape
'' Backslash : \
'' Backslash !: \
'' Backslash $: \\
Differences from QB
- New to FreeBASIC
See also