[comp.os.vms] DCL problems

fritz@unocss.unl.EDU (Tim Russell) (03/17/88)

Hi folks,

    A professor here at UNO is having a problem with a DCL command file. He's
trying to loop through command-line parameters to a DCL procedure, by using
(what to call it?)  indirect evaluation, I guess. Anyways, here's a sample:

		$ p2 := "filename"		!Just for example
		$ count = 2
		$ temp := &p'count'
		$ t1 = temp
		$ show symbol t1

This yields the following:

		T1 = "&P2"

When what it /should/ do is assign the string "filename" to T1. Any
suggestions? DEC used an example very similar in the DCL Concepts Manual,
I believe, but it works. Any ideas what's wrong?  I've tried lots of combin-
ations of ":=" and "=" to no avail... Any help would be appreciated.
Please answer directly, as I'm not subscribed yet.

    By the way, the following works:

		$ temp = "p" + "''count'"
		$ t1 = 'temp'
		$ show symbol t1

but it seems like a kludge, and the "&" trick is supposed to work.

==============================================================================
				     |
"Bones! Help him! He's choking!"     |   Tim Russell (fritz@fergvax.unl.edu)
				     |   The University of Nebraska at Omaha
"Dammit, Jim, I'm a doctor, not a... |   Home of the Fighting Mavericks
 oh, yeah...."			     |       (as if anybody cares...)
				     |
==============================================================================

SUTTON@BRANDEIS.BITNET (03/22/88)

The problem you were having has to do with the characteristics of the :=
operator.  The "'s are optional with this kind of assignment.  If you leave
them out, the equivalence string is converted to upper case, multiple
spaces and tabs are reduced to one space and leading and trailing spaces
are removed.  The & operator is not parsed when it's used on the right side
of := or when embedded in a string, but the ' operator is.  That is why you
got "&P2" (notice that the "p" is uppercase and "count" did get translated
correctly).  Perhaps DCL skips the second phase of command processing for
:= statements?  The answer to your problem is to use the = and == operators
instead.  Here's a rewrite:

    $ p2 = "filename"
    $ count = 2
    $ temp = p'count
    $ t1 = temp
    $ show symbol t1

or

    $ p2 = "filename"
    $ count = 2
    $ show symbol p'count

The place to use the & operator is when you need to pass a symbol as part
of a "command":

    $ p2 = "*.*"
    $ count = 2
    $ directory &p'count

You know, I remember these rules more by instinct than by rote.  Anyway,
I stick to using := and :== to make alliases for commands in my LOGIN.COM
file:

    $ dr :== directory/date/protection
    $ com :== @com:compile.com x
        .
        .
        .

SUTTON@BRANDEIS.BITNET

P.S. One more tip.  If you want to find out if a symbol exists, (that is,
if you got to the end of the parameters), say:

    $ loop1: if f$type(p'count).eqs."" then goto end_loop1
        .
        .
        .
    $     count = count+1
    $     goto loop1
    $ end_loop1: