Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!munnari!murdu!u3369429 From: u3369429@murdu.OZ (Michael Bednarek) Newsgroups: comp.os.vms Subject: Re: VMS weirdness (aka The DCL "&" operator) Message-ID: <1325@murdu.OZ> Date: Fri, 13-Nov-87 23:52:45 EST Article-I.D.: murdu.1325 Posted: Fri Nov 13 23:52:45 1987 Date-Received: Tue, 17-Nov-87 03:48:58 EST References: <8711081040.AA04841@ucbvax.Berkeley.EDU> <1789@charon.unm.edu> <8711120058.AA11607@ucbvax.Berkeley.EDU> Followup-To: comp.os.vms Organization: I.A.E.S.R., Melbourne University Lines: 67 Keywords: symbol apostrophe ampersand substitution DCL_compiler In article <1789@charon.unm.edu> sdowdy@charon.UUCP (Stephen Dowdy) writes: >in response to <8711081040.AA04841@ucbvax.Berkeley.EDU> > SERAFINI%TOM@IO.ARC.NASA.GOV >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 Wrong. I tried it and it doesn't work. It would work, however, if: $ b:="A" Anyway, this is not a particularly well chosen example, as $ write sys$output " ",'b produces the same result. It still surprises me that your example, if uppercase A is used, works. Quoted from VAX/VMS DCL Dictionary section 6.2.2: "You cannot use ampersands to request substitution within characters strings enclosed in quotation marks." Your enclosed ALIAS procedure uses the same format: >$ Write Sys$Output "[ALIAS] ""''P1'"" = ""''&P1'""" and it works, even if DCL's uppercasing is inhibited, e.g.: $ @alias "say" ! gives: [ALIAS] "say" = "Write Sys$Output" Again, the use of `&' is not really mandatory in ALIAS, it could be re-written: $ Write Sys$Output "[ALIAS] """,P1,""" = """,'P1,"""" So, where are ampersands really necessary? In subscripted variables! F'rinstance VMS_SHAR needs a character array `File(500)*255' (Fortran syntax) to store all filenames to be packaged. It sets up a counter, say `n', and for each filename encountered, stores it in "File'n". Then to run CHECKSUM on each file: "$ Checksum &File'n" DCL will first substitute "'n", giving e.g. "1", resulting in "&File1", which will be substituted by its definition, the filename. The obvious advantage over other HLLs is the lacking necessity of declaring the size of the array beforehand. (And you thought a DCL compiler would be possible? It isn't.) >Unfortunately, this works only for variables that are defined using ":=", not >using "=". (I personally think using "=" is generally more useful.) ??? Which VMS version are you running? >$! Title: Alias.Com >$! Purpose: To assign or return the value of a (or all) symbol(s) >$! An "act-alike" to Unix "alias" What's wrong with `$ Show Symbol ' and '$ =[=]""'? To simulate `alias', you need at least PIPE by KENW@NOAH.ARC.CDN (Ken Wallewein). Michael Bednarek Institute of Applied Economic and Social Research (IAESR) Melbourne University, Parkville 3052, AUSTRALIA, Phone : +61 3 344 5744 Domain: u3369429@{murdu.oz.au | ucsvc.dn.mu.oz.au} or mb@munnari.oz.au "bang": ...UUNET.UU.NET!munnari!{murdu.oz | ucsvc.dn.mu.oz}!u3369429 "POST NO BILLS."