[Info-vax] puzzled by DCL symbol substitution

AEF spamsink2001 at yahoo.com
Tue Jan 10 19:09:28 EST 2012


On Jan 7, 8:49 am, AEF <spamsink2... at yahoo.com> wrote:
> On Jan 7, 8:36 am, AEF <spamsink2... at yahoo.com> wrote:> On Jan 7, 7:19 am, hel... at astro.multiCLOTHESvax.de (Phillip Helbig---
>
> [...]
>
>
>
>
>
>
>
>
>
>
>
> > Example:
>
> > $ ZERO = "ONE"
> > $ ONE = "TWO"
> > $ TWO = "THREE"
> > $
> > $ A = "''ZERO'"
> > $ SH SYM A
> >   A = "ONE"
> > $
> > $ A = "''&ZERO'"
> > $ SH SYM A
> >   A = "TWO"
> > $
> > $ A = "&ZERO"
> > $ SH SYM A
> >   A = "&ZERO"
> > $
>
> > As you can see in the second case, the symbol "A" gets its value
> > before any subsequent code is executed.
>
> > > Does anyone know who invented this?
>
> > The authors of DCL.
>
> > No, this is not documented in the manuals, but that's how it works. On
> > the other hand, isn't this just like the apostrophes forcing the
> > lexical function to be evaluated in line 2 or your procedure? It is.
> > It's the same thing. Lexical substitution is normally done during
> > phase 3, but the apostrophes force it to be carried out in step 1.
>
> > AEF
>
> Here's another fun one:
>
> $ SET VERIFY
> $ TYPE COMMENT.COM
> $ ! DIR = '&DIR'
> $ @COMMENT
> $ ! DIR = 'DIRECTORY/SIZE=ALL/DATE /WIDTH=(FILE=29,SIZE=7)'
> $
>
> There are more fun things that can be done with the ampersand. I'll
> post them later when I have time.
>
> AEF

Here they are! From an old post of mine from 15-jun-2008:

Uses for the ampersand (&):

1. Simulate 1-D arrays.

2. Perform up to three iterations of symbol substitution in a single
expression.

3. Comment processing (symbol substitution within comments).

4. Avoid having to use quotation marks and apostrophes to perform
symbol substitution for a qualifier keyword containing a space.

5. Hide unprintable characters from SYS$OUTPUT (when command
verification is enabled) while at the same time avoiding the use of
quotation marks.

6. Implement "delayed-evaluation error labels".

7. Special use in PIPE command to facilitate the passing of the value
of a symbol from a PIPE subprocess back to the main process.

8. Can be used to make symbol substitution more secure in captive
command procedures.

AEF



More information about the Info-vax mailing list