[Info-vax] puzzled by DCL symbol substitution
AEF
spamsink2001 at yahoo.com
Tue Jan 17 19:54:35 EST 2012
On Jan 7, 12:46 pm, hel... at astro.multiCLOTHESvax.de (Phillip Helbig---
undress to reply) wrote:
> In article
> <09f5e110-6aa3-44f0-a0bc-d40559d2f... at z1g2000vbx.googlegroups.com>, AEF
>
> <spamsink2... at yahoo.com> writes:
> > > > The second line is "magic", too. Quotation marks normally have to be
> > > > doubled inside a quoted string, but this is the exception. The
> > > > quotation marks around PROCEDURE and NAME must *not* be doubled. For
> > > > some reason it's different when lexical functions are used in this
> > > > manner.
>
> > > Right. This is another case, though, and is documented.
>
> > Please tell me where. I don't recall ever seeing anything in the
> > manuals telling you that you must not double up quotation marks inside
> > a lexical function being substituted within a quoted string. There is
> > an example somewhere in the manuals that has an example DCL procedure,
> > one of whose lines just happens to do this, but nowhere do the manuals
> > tell you to not double up the quotation marks in this case.
>
> Right. I was sure I had seen an example in the manuals, and of course
> there are examples in the DCL procedures supplied with VMS. It should
> be mentioned in the manual as well, of course.
>
> Are there examples of ''&SYMBOL' anywhere in the DCL procedures supplied
> with VMS? A quick search found something superficially similar:
>
> SYS$COMMON:[SYSMGR]DECW$STARTAPPS.COM;1
>
> $ define/system/exec/nolog 'P2' "''F$EDIT(&P1,"UPCASE")'"
>
> Interestingly, it doesn't work if one uses this as a one-line procedure,
> but removing the "&" makes it work. Discuss.
You don't need more than one line as long as the value of P1 is also a
symbol.
Example:
$ ZERO:=ONE
$ ONE:=TWO
$ TWO:=THREE
$ THREE:=FOUR
$
$ EV F$STRING("ZERO")
ZERO
$ EV F$STRING('ZERO')
TWO
$ EV F$STRING(&ZERO)
TWO
$ EV F$STRING("''ZERO'")
ONE
$
$ SHOW SYMBOL EV
EV*ALUATE == "WRITE SYS$OUTPUT"
$
In the first case you simply have ZERO in quotation marks and that's
your string.
In case 2, first phase of symbol substitution changes 'ZERO' to ONE.
Now you have ONE as a symbol which the lexical function evaluates,
giving TWO.
In case 3, second phase changes &ZERO to ONE, and the rest follows as
in case 2. Apparently, even though you cannot use & in the middle of
an alphanumeric string (example: FIRST&SECOND), you can use it after a
parenthesis. Apparently, the parenthesis is a special character. From
the manual:
An ampersand must follow a delimiter (any blank or special character).
So it's not even really necessary, though it's interesting. You might
think it saves a character, but you don't need the trailing
apostrophe:
> > Back to VMS: Does it say anywhere that COPY NL: filename creates a new
> > file? And there are some other tricks I can look up as examples.
>
> Why would it NOT create a new file?
Well, COPY copies a file. So if there is no file to copy, it can't
perform its function. You can't run $ RENAME NLA0: blah ! because
RENAME renames files, not devices. On the other hand, you could
consider COPY NL: <filename> to work like a photocopy machine -- sort
of -- in which case it makes sense -- sort of. If you don't place a
document in the photocopy machine, pressing Start will make a copy of
the bottom of the thing that swings down to the platen. If you leave
it open, you don't really get a copy of anything, except the
accidental pattern that exists at the platen from all the light coming
from the lights in the area.
[...]
AEF
More information about the Info-vax
mailing list