User Tools

Site Tools


symbol_substitution

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
symbol_substitution [2018/11/20 16:22]
lricker clarifications
symbol_substitution [2018/11/20 22:52]
lricker
Line 9: Line 9:
   - Use the **value** of a //​variable//​ (symbol) in or on a command line   - Use the **value** of a //​variable//​ (symbol) in or on a command line
   - Substitute (interpolate,​ or insert) the **value** of a //​variable//​ into a quoted-string of text   - Substitute (interpolate,​ or insert) the **value** of a //​variable//​ into a quoted-string of text
-  - Substitute (interpolate,​ or insert) the **value** of a //[[DCL Lexical Function]]//​ into a quoted-string of text+  - Substitute (interpolate,​ or insert) the **value** of a //[[DCL Lexical Functions|DCL Lexical Function]]//​ into a quoted-string of text
  
 You'll find these techniques and uses of string substitution primarily in DCL command files, or scripts, which exploit many of the same programming techniques as those more modern scripting languages. You'll find these techniques and uses of string substitution primarily in DCL command files, or scripts, which exploit many of the same programming techniques as those more modern scripting languages.
Line 105: Line 105:
 ==== Producing Quotes in Quotes ==== ==== Producing Quotes in Quotes ====
  
-What if you want to produce literal double-quote marks to be printed in a string of text? -- like:+What if you want to produce literal double-quote marks to be printed in a string of text? -- like this:
  
 <​code>​ <​code>​
Line 111: Line 111:
 </​code>​ </​code>​
  
-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:+...or surround some text with single quotes? -- like this:
 <​code>​ <​code>​
-$ WRITE sys$output "This is ""​double-quoted-text""​."​ +This is '​singled-quoted-text'.
-                   ​| ​       ^^                  ^^ |   ! Use two double-quotes where you want one printed, +
-                   ​^ ​                              ​^ ​  ! and these two double-quotes delimit the literal string.+
 </​code>​ </​code>​
  
-...or: +These are pretty common use-cases -- See the wiki article [[Literal Quotes in DCL Strings]] ​for full details.
-<​code>​ +
-$ 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. +
-</​code>​ +
- +
-...or: +
-<​code>​ +
-$ 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 +
-</​code>​ +
- +
-...or even: +
-<​code>​ +
-$ 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. +
-</​code>​ +
- +
-This suggests a similar way to produce a //literal __single__-quote mark (tick)// in text: +
-<​code>​ +
-$ SQUOTE = "'" ​  ! Create a variable whose value is a single single-quote mark! +
-$ WRITE sys$output "This is ", SQUOTE, "​singe-quoted-text",​ SQUOTE, "​."​ +
-</​code>​ +
- +
-...or: +
-<​code>​ +
-$ SQUOTE = "'" ​  ! Create a variable whose value is a single single-quote mark! +
-$ WRITE sys$output "This is " + SQUOTE + "​singe-quoted-text"​ + SQUOTE + "​."​ +
-</​code>​ +
- +
-...both produce: +
-<​code>​ +
-This is '​single-quoted-text'​. +
-</​code>​+
  
 ==== Command File Parameters P1 thru P8 ==== ==== Command File Parameters P1 thru P8 ====
symbol_substitution.txt · Last modified: 2018/11/20 22:52 by lricker