From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 21-SEP-1989 04:22
To:	MRGATE::"ARISIA::EVERHART"
Subj:	RE: DCL question on quotes

Message-Id:  <8909210822.AA26125@crdgw1.ge.com>
Received: From CUNYVM.CUNY.EDU by CRVAX.SRI.COM with TCP; Thu, 21 SEP 89 00:56:52 
Date:    Thu, 21 Sep 1989 09:55:50  +0200
From: "GWDGV1::MOELLER"  <U0012%DGOGWDG5.BITNET@CUNYVM.CUNY.EDU>
To: info-vax@sri.COM
Subject: RE: DCL question on quotes

Jim Kirkpatrick <jimkirk@CORRAL.UWYO.EDU> asks:
> I have a problem that I hope is an easy DCL problem to work around.
> This deals with DCL's failure to "properly" handle quotes (").
> ...
>       $ read f2/key="''rkey'" info
>
> This works fine unless the extracted key has a quote in it, when it fails.
> It is even worse if the key is something like this --
>       DEAN"S OFFICE, GRADUATE SCHOOL
> ...

Indeed, single and double quotes are handled very specially by DCL,
and you have to use a special device for each one.
DCL does transparently handle the remaining 254 bytes, so you can have
"binary" keys if you like.

(a) Single quotes cannot be handled by the "''SYMBOL'" construct.
    To avoid the problem, you have to use the construct &SYMBOL
    which can be used in its place.
(b) Double quotes must always be escaped by doubling and quoting,
    even in symbols passed by &SYMBOL .
    For instance, to pass DEAN"S, you have to make up a symbol
    which contains "DEAN""S" and pass that by means of & .

Incidentally, I found this out when trying to $REPLY an arbitrary string;
$REQUEST also comes to mind.

As for the code, the only problem is to escape the double quotes.
The following piece of DCL is my solution to the poster's problem:

$! if RKEY has any `"' in it, quote it and double the `"'s
$!
$ NEWKEY=RKEY
$ if f$locate("""",RKEY).eq.f$length(RKEY) then goto qq_end     ! no `"'
$ i=0
$ NEWKEY=""
$qq_loop:
$ chunk=f$element(i,"""",RKEY)          ! get a segment that has no `"' in it
$ if chunk.eqs."""" then goto qq_end
$ NEWKEY=NEWKEY+""""+chunk+""""         ! add `"'s
$ i=i+1
$ goto qq_loop
$qq_end:
$!
$ read/key=&NEWKEY f2 info

Hope this helps
        -wjm

Wolfgang J. Moeller, GWDG, D-3400 Goettingen, F.R.Germany | Disclaimer ...
Bitnet/Earn: U0012@DGOGWDG5         Phone: +49 551 201516 | No claim intended

