Operating System - OpenVMS
1748212 Members
3995 Online
108759 Solutions
New Discussion юеВ

Re: DCL syntax - symbol substitution - DCL_CHECK.COM warning

 
SOLVED
Go to solution
Art Wiens
Respected Contributor

DCL syntax - symbol substitution - DCL_CHECK.COM warning

I thought I'ld try the much heralded DCL_CHECK.COM procedure on some of the command procedures I've written. I get this message on something that I thought was correct:

LINE CODE --DIAGNOSTIC MESSAGE--
108 PRQ probable error using single-quote (')

It comes about when I set a local string symbol with:

$ SEARCH_WAIT_TIME := "00:03:00"

and use it later with:

$ WAIT 'SEARCH_WAIT_TIME

It definately works, it's been in use every 3 minutes for about a year.

Is it "wrong"?

Art
19 REPLIES 19
Uwe Zessin
Honored Contributor
Solution

Re: DCL syntax - symbol substitution - DCL_CHECK.COM warning

I think the correct way is to surround the symbol:

$ WAIT 'SEARCH_WAIT_TIME'

Sometimes it is possible to leave off quotes like in (no '"' at the end):

$ write sys$output "bla
bla
$
.
Keith Cayemberg
Trusted Contributor

Re: DCL syntax - symbol substitution - DCL_CHECK.COM warning

Hi Art,

well, I suppose if it works for you it's not totally wrong. I tried it and appears DCL is discarding your extra set of quotes...

$ SEARCH_WAIT_TIME := "00:03:00"
$ show symbol SEARCH_WAIT_TIME
SEARCH_WAIT_TIME = "00:03:00"

Correct form with the := and :== operators is to not use explicit quotes since all text to the right of the operator is already implicitly quoted...

$ SEARCH_WAIT_TIME := 00:03:00
$ show symbol SEARCH_WAIT_TIME
SEARCH_WAIT_TIME = "00:03:00"

Or, you could use the = or == operators which do not perform implicit quoting. Then it would be correct form to include explicit quotes.

$ show symbol SEARCH_WAIT_TIME
$ SEARCH_WAIT_TIME = "00:03:00"

I'm not sure if your method could result in substitution problems or limitations if the quoting and symbol substitution were signicantly more complicated than your example.

I was using...
$ show system/noproc
OpenVMS V7.3-2 on node CH21 27-SEP-2004 20:19:28.73 Uptime 28 07:04:01


Cheers!

Keith Cayemberg
Keith Cayemberg
Consultant
Wipro Technologies
Keith Cayemberg
Trusted Contributor

Re: DCL syntax - symbol substitution - DCL_CHECK.COM warning

Ah, Yes. Uwe is correct. I was looking in the wrong place. The DCL_CHECK was definitely complaining about the unbalanced single quoting of the WAIT command substitution. Yes it works often. But it's bad form, and unsupported. Here, I believe there are cases where you can also get yourself in trouble.

Cheers!

Keith
Keith Cayemberg
Consultant
Wipro Technologies
Wim Van den Wyngaert
Honored Contributor

Re: DCL syntax - symbol substitution - DCL_CHECK.COM warning

DCL_CHECK is not a compiler. It TRIES to understand what is in the dcl procedure.
It is possible to write scripts that are 100% warning free but sometimes you have to find a warning free syntax. E.g. goto's to a value of a symbol are hard to understand. E.g. symbol substitution. E.g. label formats (balnks before :).

Today I posted a dcl_check in zhich I cleaned out some of the messages that I found redundant (for me).

Wim
Wim
Art Wiens
Respected Contributor

Re: DCL syntax - symbol substitution - DCL_CHECK.COM warning

I've been re-reading "Writing Real Programs in DCL 2nd Edition" by Paul Anagnostopolous and Steve Hoffman ... Chapter 5 - page 66 :

"The "official" syntax for sustitution calls for one trailing apostrophe; however, it is unnecessary in many cases." ... and then goes on to list the specific situations where it is. My situation it's not.

Another good quote is on page 68:

"Programmers are often confused about the context in which apostrophe substitution is required, and this results in overuse of the construct."

Just trying to live "by the book".

Thanks,
Art
Wim Van den Wyngaert
Honored Contributor

Re: DCL syntax - symbol substitution - DCL_CHECK.COM warning

Art,

I use 2 methods only (risk ?)
1) "''symbol'"
2) 'symbol'

Format 2 has no discussion of where the symbol ends. Why use the 'symbol ?

Of couse, dcl_check should recognize al formats but I think the author was convinced that my/his formats are the real ones.

Wim
Wim
Art Wiens
Respected Contributor

Re: DCL syntax - symbol substitution - DCL_CHECK.COM warning

"Why use the 'symbol "

'Cause if Steve Hoffman tells me it's unneccesary, I should probably listen!

;-)
Art
Ian Miller.
Honored Contributor

Re: DCL syntax - symbol substitution - DCL_CHECK.COM warning

the trailing quote is unecessary for the correct execution of the DCL but so are comments :-)
I think the DCL_CHECK author is suggesting its better style always to including for those occations when it is necessary.
____________________
Purely Personal Opinion
Sheldon Smith
HPE Pro

Re: DCL syntax - symbol substitution - DCL_CHECK.COM warning

A DCL symbol is limited to alphanumerics, dollar, hyphen and underscore. While the trailing apostrophe/single quote may be esthetically better (read "balanced"), when followed by whitespace it is definitely optional.

Note: While I am an HPE Employee, all of my comments (whether noted or not), are my own and are not any official representation of the company

Accept or Kudo