literal_quotes_in_dcl_strings
Literal Quotes in DCL Strings
What if you want to produce literal double-quote marks to be printed in a string of text? – like this:
This is "double-quoted-text".
…or surround some text with single quotes? – like this:
This is 'singled-quoted-text'.
When you want a literal double-quote mark to appear in a literal text string, you can produce it in either of these two ways:
$ WRITE sys$output "This is ""double-quoted-text""." | ^^ ^^ | ! Use two double-quotes where you want one printed, ^ ^ ! and these two double-quotes delimit the literal string.
…or:
$ DQUOTE = """" ! Create a variable whose content/value is a single double-quote mark! $ WRITE sys$output "This is " + DQUOTE, "double-quoted-text" + DQUOTE + "." $ ! This ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ $ ! concatenates several substrings (including the value of DQUOTE) into $ ! a single string for printing.
…or:
$ DQUOTE = """" ! Create a variable whose content/value is a single double-quote mark! $ message = "This is " + DQUOTE, "double-quoted-text" + DQUOTE + "." $ ! This ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ $ ! concatenates several substrings (including the value of DQUOTE) into $ ! a single string variable for any purpose, including printing... $ WRITE sys$output message
…or even:
$ DQUOTE = """" ! Create a variable whose value is a single double-quote mark! $ WRITE sys$output "This is ", DQUOTE, "double-quoted-text", DQUOTE, "." $ ! The WRITE ^^^^^^^^^^ ^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^ ^^^ $ ! command takes several expressions (here, just literal strings) and $ ! concatenates them itself for printing.
This suggests a similar way to produce a literal single-quote mark (tick) in text:
$ SQUOTE = "'" ! Create a variable whose value is a single single-quote mark! $ WRITE sys$output "This is ", SQUOTE, "singe-quoted-text", SQUOTE, "."
…or:
$ SQUOTE = "'" ! Create a variable whose value is a single single-quote mark! $ WRITE sys$output "This is " + SQUOTE + "singe-quoted-text" + SQUOTE + "."
…both produce:
This is 'single-quoted-text'.
literal_quotes_in_dcl_strings.txt · Last modified: 2018/11/20 18:37 by lricker