[comp.os.vms] DCL qualifier parsing

rarback@bnlux0.bnl.gov (harvey rarback) (05/12/88)

I am having trouble using DCL qualifiers which take a value.  In particular,
if the value is an expression, I am not able to get DCL to evaluate the
expression.  What am I doing wrong?  (VMS version 4.4).

Here is the offending DCL:


$ module = "2" + "2"
$ library /extract='module'      fortune.tlb  ! this works
$
$ library /extract="2"+"2"       fortune.tlb
%DCL-W-PARMDEL, invalid parameter delimiter - check use of special characters
$
$ library /extract=("2"+"2")     fortune.tlb
%DCL-W-NOPAREN, value improperly delimited - supply parenthesis
$
$ library /extract=(("2")+("2")) fortune.tlb
%DCL-W-VALREQ, missing qualifier or keyword value - supply all required values


   ----
Harvey Rarback                Internet: rarback@bnlux0.bnl.gov
Brookhaven National Lab       BITNET:   RARBACK@BNLUX0
Upton, NY 11973               UUCP:     ...philabs!sbcs!bnlux0!rarback
(516)  282-3758               PHYSNET:  BNLX1::RARBACK (44166::RARBACK)

sommar@enea.se (Erland Sommarskog) (05/18/88)

Harvey Rarback (rarback@bnlux0.UUCP) writes:
>$ library /extract="2"+"2"       fortune.tlb
>%DCL-W-PARMDEL, invalid parameter delimiter - check use of special characters

Do:
$ LIBRARY/EXTRACT="''2+2'"

-- 
Erland Sommarskog           Take C, a third class language 
ENEA Data, Stockholm        and a C programmer, i.e. a third class programmer
sommar@enea.UUCP            => A ninth class program, a C program.

schuetz@iravcl.ira.uka.de (05/19/88)

	
Hello,
three days ago I posted a followup to this group - no, it was no late april
fool. We have a (not the only) bug in our vms-news-system which will evaluate
every string between double-quotes while posting it to the forward machine.
On the local machine it looks ok.

*** Please substitute every back-quote by a double-quote. ***

			--------- once again ----------
> $ module = `2` + `2`
> $ library/extract='module' fortune.tlb

is the same as $ library/extract=`22` fortune.tlb

But back to your problem: Just try
  $ library/extract ``2` + `2`` fortune.tlb

Hope this helps.

Cheers, Elmar

LEICHTER@VENUS.YCC.YALE.EDU ("Jerry Leichter ", LEICHTER-JERRY@CS.YALE.EDU) (05/24/88)

	Harvey Rarback (rarback@bnlux0.UUCP) writes:
	>$ library /extract="2"+"2"       fortune.tlb
	>%DCL-W-PARMDEL, invalid parameter delimiter - check use of special
		characters

	Do:
	$ LIBRARY/EXTRACT="''2+2'"

When did you start running VMS V6.0?  :-)

This doesn't work in any version of VMS I've ever seen, it's actually equiva-
lent to the (rather unlikely) command:

	$ LIBRARY/EXTRACT="+2'"

DCL does not have any syntax for specifying expression evaluation at arbitrary
places in the input.  What it you CAN specify is SUBSTITUTION OF SYMBOLS, a
much more limited thing.  Expression evaluation occurs in certain well-defined
contexts, such as after an "=", ONLY.  The original author's problem can be
solved easily in two statements:

	$ value = "2" + "2"
	$ LIBRARY/EXTRACT="''value'"
(or	$ LIBRARY/EXTRACT=&value)

This is a bizzare example, actually, since I THINK the original author is
expecting to extract module 4 - but he will actually get module 22.  The "+"
is polymorphic; it adds integers, but concatenates strings.  In most cases in
DCL, the two are freely interchangeable, but here the difference is noticable:

	$ value = "2" + "2"	!Two strings, result "22"
	$ value = 2 + 2		!Two integers, result 4
	$ value = "2" + 2	!String coerced to integer, result 4

If it was indeed "22" that the original author wanted, there is a one-line
solution (the point of which is only visible if you use variables):

	$ X1 = "2"
	$ X2 = "2"
	$ LIBRARY/EXTRACT="''X1'''X2'"

Concatenation is an implicit side-effect of substitution, so no evaluation is
needed.
							-- Jerry