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 revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
symbol_substitution [2018/11/19 23:55] lrickersymbol_substitution [2018/11/20 18:36] – move "Literal Quotes in DCL Strings" to separate wiki article lricker
Line 42: Line 42:
 Lines ''1'' through ''4'' are just internal documentation, and inform us that the [[Command File Parameters|DCL parameter symbol]] ''P1'' is used to collect the __name of the device to show__ from the command line; if the user does not specify that device name on the command line (tested at Line ''5''), s/he is prompted for it at Line ''6''; if P1 is specified on the command line, its value is simply copied to the variable (symbol) ''dev'' at Line ''7''. Lines ''1'' through ''4'' are just internal documentation, and inform us that the [[Command File Parameters|DCL parameter symbol]] ''P1'' is used to collect the __name of the device to show__ from the command line; if the user does not specify that device name on the command line (tested at Line ''5''), s/he is prompted for it at Line ''6''; if P1 is specified on the command line, its value is simply copied to the variable (symbol) ''dev'' at Line ''7''.
  
-In either case, that variable ''dev'' is recomputed (overwritten) by assigning the result of the lexical function ''F$GETDVI'' at Line ''8''; the function's argument ''"DEVNAM"'' makes it look up the proper physical device name for whatever is specified as its first input argument (again by the ''dev'' variable's initial value).  And Line ''12'' re-uses that lexical function to test (determine) whether or not that physical device is a Shadow-Set Volume.+In either case, that variable ''dev'' is recomputed (overwritten) by assigning the result of the __lexical function__ ''F$GETDVI'' at Line ''8'' (an example of #3 from the list above); the function's argument ''"DEVNAM"'' makes it look up the proper physical device name for whatever is specified as its first input argument (again by the ''dev'' variable's initial value).  And Line ''12'' re-uses that lexical function to test (determine) whether or not that physical device is a Shadow-Set Volume.
  
-The __actual examples of string substitution__ happen at Lines ''11'', ''13'', ''14'' and ''16'' --+The __actual examples of string substitution__ (#2 from the list above) happen at Lines ''11'', ''13'', ''14'' and ''16'' --
  
 Lines ''11'', ''14'' and ''16'' are of the form (with variations): Lines ''11'', ''14'' and ''16'' are of the form (with variations):
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 ====
Line 263: Line 218:
   * Symbols preceded by single apostrophes (not in double-quotes: ''tick-varname-tick'') are translated //iteratively//; symbols preceded by double apostrophes (as in double-quotes ''"tick-tick-varname-tick"'') are not (substitution inside of double-quotes is once-only, when encountered).   * Symbols preceded by single apostrophes (not in double-quotes: ''tick-varname-tick'') are translated //iteratively//; symbols preceded by double apostrophes (as in double-quotes ''"tick-tick-varname-tick"'') are not (substitution inside of double-quotes is once-only, when encountered).
  
-  * DCL performs iterative substitutions in multiple phases or passes (for a given construct like ''&P'COUNT'''): First, any and all single-tick-mark substitutions (''tick-variable-tick'') are done -- yes, an early string substitution could result in a subst-value which itself is single-tick-mark surrounded, hence iterative substitution (very rarely done, and confusing!); then, finally, the ''&''-substitution is done on whatever symbols (variable) name results from the earlier substitution.  (Confused yet?  Take fresh courage: this is a rarely used feature of DCL!)+  * DCL performs iterative substitutions in multiple phases or passes (for a given construct like ''&P'COUNT'''): First, any and all single-tick-mark substitutions (''tick-varname-tick'') are done -- yes, an early(er) string substitution could result in a subst-value which itself is single-tick-mark surrounded, hence iterative substitution (very rarely done, and confusing!).  Then//finally//, the ''&''-substitution is done on whatever symbols (variable) name results from the earlier substitution(s).  Confused yet?  Take fresh courage: this is a rarely used feature of DCL!
  
 The upshot of this is simply that the ''&''-substitution operator delays its own substitution until any and all earlier tick-mark-substitutions have been done.  So, looking again at the previous example: The upshot of this is simply that the ''&''-substitution operator delays its own substitution until any and all earlier tick-mark-substitutions have been done.  So, looking again at the previous example:
Line 275: Line 230:
        are displayed.        are displayed.
 </code> </code>
- 
  
symbol_substitution.txt · Last modified: 2018/11/20 22:52 by lricker

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki