From: CSBVAX::MRGATE!@KL.SRI.Com:info-vax-request@kl.sri.com@SMTP 11-NOV-1987 00:29 To: EVERHART Subj: Re: VMS weirdness Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Tue 10 Nov 87 17:23:15-PST Received: by ucbvax.Berkeley.EDU (5.58/1.27) id AA05345; Tue, 10 Nov 87 16:31:02 PST Received: from USENET by ucbvax.Berkeley.EDU with netnews for info-vax@kl.sri.com (info-vax@kl.sri.com) (contact usenet@ucbvax.Berkeley.EDU if you have questions) Date: 9 Nov 87 20:40:10 GMT From: unmvax!charon!sdowdy@ucbvax.Berkeley.EDU (Stephen Dowdy) Organization: University of New Mexico, Albuquerque, NM Subject: Re: VMS weirdness Message-Id: <1789@charon.unm.edu> References: <8711081040.AA04841@ucbvax.Berkeley.EDU> Sender: info-vax-request@kl.sri.com To: info-vax@kl.sri.com In article <8711081040.AA04841@ucbvax.Berkeley.EDU> SERAFINI%TOM@IO.ARC.NASA.GOV writes: >I came across something today by accident that I find very interesting, so I >thought I'd tell everyone. At DCL level, entering a line with only a "&" >on it will instantly crash your process, with some kind of signal error. I have no explanation for that as i can't duplicate it. >Typing the & embedded in a command line seems to cause the rest of the command >after the & to be ignored, like a comment. Does anybody know the explanation >for this. From the text below, you will see that this is similar to putting a single ' at the end of a line; DCL interprets it as a null symbol substitution. > >If the answer if RTFM, just say so, because I haven't. Even if it's documented, >it hardly seems like appropriate behavior. As far as i know, this operator is documented in one of the DCL user's manuals, but not very well (like in the middle of a paragraph that is of little reference). In general, it is probably best to leave it (&) alone since it isn't documented very well, and therefore could cause maintenance problems (ala "what the *#$^#*&@ is this?"). > >David Serafini The "&" symbol is used by DCL as an "indirect substitute variable" directive. It is similar in function to the "'" directive, but carries the substitution one step further. It uses the contents of a symbol to refer to a symbol that should be operated on. An example: $ a := "hello" $ b := "a" $ write sys$output " ''b'" a $ write sys$output " ''&b'" hello Unfortunately, this works only for variables that are defined using ":=", not using "=". (I personally think using "=" is generally more useful.) The following command file exhibits the use of the "&" DCL operator. In this case the "&" is used to resolve the value of a symbol that is passed by the name "P1", the first parameter to the script. ----------- Cut 'n' Snip (tm) -------------------------------------------------- $!############################################################################## $! Title: Alias.Com $! Purpose: To assign or return the value of a (or all) symbol(s) $! An "act-alike" to Unix "alias" $! Author: Stephen Dowdy (University Of New Mexico) $! Date: 6/19/86 $!############################################################################## $! Usage: $ alias [ symbol [substitution] ] $! $ alias display all symbol definitions $! $ alias symbol display value of "symbol" $! $ alias symbol value assign "value" to "symbol" $!.............................................................................. $ If (P1 .EQS. "") Then Goto Display_All $ If (P2 .EQS. "") Then Goto Display_One $!...Assign value to symbol using the rest of the command line $ P2 = P2 + " " + P3 + " " + P4 + " " - + P5 + " " + P6 + " " + P7 + " " + P8 ! concatenate $ 'P1' :== 'P2' ! Global define $ Goto Display_One ! show new definition $!... $!...Show all symbols $ Display_All: $ Write Sys$Output "[ALIAS] Current Global Symbol Definitions..." $ Show Symbol/All/Global $ Goto Exit $!... $!...Show the value of one symbol $ Display_One: $!...Here, we don't want to do F$TYPE(P1), since this is a string value, $!...containing the name of the symbol of interest. Indirect it (&P1) to see if $!...that symbol exists. $ If (F$Type(&P1) .EQS. "") Then Goto Sym_Not_Def $!...Write out the contents of the contents of P1 $ Write Sys$Output "[ALIAS] ""''P1'"" = ""''&P1'""" $ Goto Exit $ Sym_Not_Def: $ Write Sys$Output "[ALIAS.ERROR] ""''P1'"" Not Defined" $ Goto Exit $ Exit: $ Exit ----------- Cut 'n' Snip (tm) -------------------------------------------------- --stephen dowdy -- $!####################################################################### $! stephen dowdy (UNM CIRT) Albuquerque, New Mexico, 87131 (505) 277-8044 $! Usenet: {convex,ucbvax,gatech,csu-cs,anl-mcs}!unmvax!charon!sdowdy $! BITNET: sdowdy@unmb $! Internet: sdowdy@charon.UNM.EDU $! Team SPAM in '87! SPAAAAAAAAAAAAAAAAAAAAMMMMMMM! $!#######################################################################