Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ucbvax!VENUS.YCC.YALE.EDU!LEICHTER From: LEICHTER@VENUS.YCC.YALE.EDU ("Jerry Leichter ", LEICHTER-JERRY@CS.YALE.EDU) Newsgroups: comp.os.vms Subject: Forcing expression evaluation in DCL Message-ID: <8805280454.AA02287@ucbvax.Berkeley.EDU> Date: 26 May 88 14:05:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 28 In a recent message, I said that DCL provided a syntax for specifying SYMBOL SUBSTITUTION anywhere (the apostrophe), but no mechanism for specifying GENERAL EXPRESSION EVALUATION. After thinking about it a bit more, I realized that this is false: Since symbol substitution includes evaluation of lexicals, and evaluation of lexicals can cause general expression evaluation, you can get the effect by using the F$STRING() lexical in an unexpected way. Thus, suppose X1 and X2 contain integers and, for whatever reason, you want to create a file whose name is the sum of the two integers. The direct approach is: $ X = X1 + X2 $ CREATE 'X' The DCL hacker's approach is: $ CREATE 'F$STRING(X1 + X2)' You can use any expression you like as an argument to F$STRING. If you want an integer, rather than a string, result, you can use F$INTEGER instead. I can't see any way to make this polymorphic (i.e., get back a string or integer depending on what the expression evaluated to), but I also can't think of any reason why you'd want to do that. Of course, this works for quoted strings, too: $ SEARCH/EXACT FILE.TXT "The number is ''F$STRING(X1 + X2)'" -- Jerry