T.R | Title | User | Personal Name | Date | Lines |
---|
97.1 | | WEBSTR::BEYER | | Thu Mar 07 1985 14:59 | 12 |
| I've been known to search the parameter for lowercase and embedded
spaces to decide whether it needs quotes added back on. Adding the
quotes is easy: MAIL/SUBJ="""''P2'"""
What I really need is a way to keep quotes embedded in a parameter
from screwing up its use. That is, if the user passes the string
"foo ""bar""", P2 is {foo "bar"} and the above turns into
{MAIL/SUBJ="foo "bar""}, and mail bitches because it tried to parse 'bar'.
It would be a lot simpler if DCL didn't strip double quotes for you.
HRB
|
97.2 | | TURTLE::GILBERT | | Thu Mar 07 1985 20:27 | 10 |
| (In my considered opinion) the DCL behaviour you describe is correct and
reasonable. The problem is in how you're embedding the value of a string
within quotes; you should double any quotes that are in the string. Sadly,
there's no easy way to do that from DCL.
This is a perfect example of where the ampersand (&) should be used, e.g.,
{MAIL/SUBJ=&P2}. However, this doesn't seem to work correctly -- although
DCL doesn't complain, the quotes in P2 are removed. But this may solve a
few problems.
- Gilbert
|
97.3 | | SPEEDY::BRETT | | Thu Mar 07 1985 20:49 | 20 |
| Why did you put all those ''s in? "Modern" DCL should be pretty well void
of := and of '.
For instance...
if "''p1'" .eqs. ...
should be
if p1 .eqs. ...
The best trick is how to define a symbol if it doesn't exist, but not change
it if it does. I use
MAKE_THIS_SYMBOL_EXIST[0,0] = 0
/Bevin
|
97.4 | | REX::MINOW | | Fri Mar 08 1985 11:39 | 7 |
| Sounds like .3 trades "''p1'" for p1[0,0] = 0 -- an even trade, but
thanks for the hint.
Still no real solution? -- note I'm using NMAIL, not MAIL -- if that
makes a difference.
Martin.
|
97.5 | | WEBSTR::BEYER | | Fri Mar 08 1985 11:59 | 9 |
| I don't see how &P1 helps the problem any. I pulled out the documentation
on it, and it seems to be just a delayed 'P1'. What's really needed here
is a way get the literal sequence of characters typed for a parameter,
complete with surrounding quotes and embedded double quotes.
.0 is probably like me.. I learned "''foo'" early on and the substitution
rules for DCL were so persnickity I've done it exactly that way ever since.
HRB
|
97.6 | | VAXUUM::DYER | | Fri Mar 08 1985 16:12 | 2 |
| The double-quote behavior in .COM files is an utter crock.
#6 <_Jym_>\
|
97.7 | | TURTLE::GILBERT | | Fri Mar 08 1985 19:15 | 47 |
| Consider the example:
$! Does P1 contain a quote character?
$!
$ if f$locate("""",p1) .ge. f$length(p1) then write sys$output "Yes"
re .1 (HRB) and .6 (_Jym_)
If DCL didn't strip double quotes for you, you may have trouble
expressing the above example. Or (depending on what alternate
proposal you might use), you could have trouble with the following:
$ x = "Please bullet the items with a ""+"" mark"
$ x = "concatenate these " + "strings"
$ if a .eqs. "" then if b .eqs. "foo" then goto label
$ if a .eqs. """ then if b .eqs. ""foo" then goto label
Many utilities ignore this problem. For example, it's possible
to create a CMS comment that will appear as two separate CMS commands
in a CMS history (CMS automatically provides line breaks for these).
The output of SHOW LOGICAL doesn't double quotes -- it's possible
to create a logical name that is displayed ambiguously. When Cobol
extracts definitions from the CDD, producing Cobol source text, it
*does* re-double the quotes for string literals (you *have* to get it
right if the output is to be used by some nit-picky computer).
re .5 (HRB)
I almost expected &P1 to do the trick. It's a little different
than a delayed 'P1'. In the case of the mail example, if P2 is
{foo "bar"}, then {MAIL/SUBJ=&P2} causes no DCL complaints, while
a wide range of alternatives can or do cause errors.
After seeing that {MAIL/SUBJ=&P2} gave no complaints, I was pleased,
and expected to see {foo "bar"} in the subject line of the message.
Unfortunately, the subject was given as {foo bar} -- how or why it
managed to realize that P2 was a single entity, but failed to retain
the embedded quotes, I don't know. However, it *does* solve this
particular problem (no DCL errors), if you're willing to forgive a
few missing quotes from the subject of the message.
Yes, what's needed is a way to get embedded quotes doubled again.
It's a relatively simple matter to code a little loop to do this.
A more convenient way to do this (perhaps another f$edit option)
is desired.
- Gilbert
|
97.8 | | MAHLER::FISHER | | Tue Mar 12 1985 16:27 | 8 |
| RE .4 how to define a symbol if it doesn't exist, but
not change it if it does.
$if f$type("symbol") .eqs. "" then symbol = "whatever"
Bye
Kay R. Fisher
|
97.9 | | PARVAX::PFAU | | Wed Mar 13 1985 18:41 | 3 |
| What if you are running V3?
tom_p
|
97.10 | | ELGAR::FISHER | | Tue Mar 19 1985 09:50 | 12 |
| If it's a number - it's easy
symbol = 0'symbol'
!If it wasn't defined before - it is now.
!It is was - it has the same value.
!I used this for debugging DCL
Debug = 0'Debug'
Bye
Kay R. Fisher
|
97.11 | | RANI::LEICHTERJ | | Tue Mar 26 1985 21:21 | 16 |
| What's wrong with:
$ symbol = "''symbol'"
(Yes, the result is always a string; if you are know you need an integer you
can always do something like what is suggested in .-1.)
Note that, in this particular case, "=" and ":=" are equivalent. What you
should NOT do is:
$ symbol := 'symbol'
Besides screwing around with case, spacing, and quotes, and trying to execute
any substrings of symbol that look like calls to lexicals, this can have unex-
pected results if symbol ends with a "-".
-- Jerry
|
97.12 | | EIFFEL::BRETT | | Wed Mar 27 1985 11:54 | 11 |
| $ symbol = " "" ! What a comment "
then
$ symbol = "''symbol'" becomes
= " " ! What a comment "
so the value of the symbol is not preserved.
/Bevin
|
97.13 | | REX::MINOW | | Wed Mar 27 1985 15:56 | 7 |
| .12 brings us full circle back to my original question (if anyone cares):
HOW DO I PRESERVE QUOTES IN .COM FILES?
What kind of hackers are you? It can't be that difficult. (:-)
Martin.
|
97.14 | | TOOLS::GILBERT | | Wed Mar 27 1985 17:33 | 31 |
| $! send a wildcarded set of files to a destination using nmail
$! Two mandatory parameters:
$! P1 file to send (argument to f$search())
$! P2 destination (don't forget to quote arpa addresses)
$!
$ if P1 .eqs. "" then read sys$command P1 /prompt="Wildcard filespec to send: "
$ if P1 .eqs. "" then exit
$ if P2 .eqs. "" then read sys$command P2 /prompt="Destination (don't forget quotes): "
$ if P2 .eqs. "" then exit
$ loop: file = f$search(P1)
$ if file .eqs. "" then exit
$
$ P0 = file
$ return = "goto 10$"
$ goto dq
$ 10$: file = P0
$
$ P0 = P2
$ return = "goto 20$"
$ goto dq
$ 20$: P2 = P0
$
$ nmail/notime "''file'" "''P2'" "File ''file'"
$ goto loop
$
$ dq: i = 0
$ dq1: i = i + f$locate("""",f$extract(i,f$length(P0)-i,P0))
$ if i .ge. f$length(P0) then 'return
$ P0 = f$extract(0,i+1,P0) + f$extract(i,f$length(P0)-i,P0)
$ i = i + 2
$ goto dq1
|