- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: Silly DCL question
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-30-2008 04:11 AM
тАО10-30-2008 04:11 AM
Silly question here...
And all because I need to justify my review comments on some DCL script that someone changed...
In DCL, why bother having the comparison operators .ne. and .nes. when DCL converts everything to the same type before the comparison anyway?
For example, all the following work:
$ IF 1 .EQS. "1" THEN WRITE SYS$OUTPUT "EQUAL"
EQUAL
$ IF 1 .EQ. "1" THEN WRITE SYS$OUTPUT "EQUAL"
EQUAL
$ IF "1" .EQ. 1 THEN WRITE SYS$OUTPUT "EQUAL"
EQUAL
$ IF "1" .EQS. 1 THEN WRITE SYS$OUTPUT "EQUAL"
EQUAL
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-30-2008 04:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-30-2008 06:00 AM
тАО10-30-2008 06:00 AM
Re: Silly DCL question
Thanks.
Unfortunately I can only give you 10 points.
You deserve twice as many.
Regards
JamesP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-30-2008 07:32 AM
тАО10-30-2008 07:32 AM
Re: Silly DCL question
$ IF "abcdef" .eq. "GHIJKL" THEN WRITE SYS$OUTPUT "same string"
same string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-30-2008 07:38 AM
тАО10-30-2008 07:38 AM
Re: Silly DCL question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-30-2008 06:15 PM
тАО10-30-2008 06:15 PM
Re: Silly DCL question
Not a silly question at all!
Jess's example shows a very common error in DCL code. I've been bitten by that one many times!
"when DCL converts everything to the same type before the comparison anyway?"
This is the source of the trouble! It doesn't convert to a common type, instead it trys to guess the approprite typefor each symbol from context. Implicit conversions can, and often do guess the wrong thing and give unexpected results. (try Basic sometime - a simple line of code can often generate a bewildering number of unexpected conversions). Another place this causes trouble in DCL is in string arithmetic:
$ x=1
$ s1="A"
$ s2="B"
$ s3=s1+s2
$ s4=s1+s2+x
The presence of a single numeric symbol changes the whole expression to numeric, so the value of s4 is (numeric) 1.
I find it safer to make all conversions explicit, using F$INTEGER and F$STRING in anything but the most simple instances. Code is more verbose, but also more robust.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-31-2008 07:36 AM
тАО10-31-2008 07:36 AM
Re: Silly DCL question
I find that using F$INTEGER(SYMBOL) in an expression (instead of just SYMBOL) is pointless, because F$INTEGER does not give an error if SYMBOL is not a numeric string.
Just like an implicit conversion, F$INTEGER converts non-numeric strings to either 0 or 1 based on the first character.
So instead of code like this:
$ I = F$INTEGER(INPUT)
I use:
$ I = 'INPUT'
which at least gives a warning message on non-numeric strings (assuming the value of INPUT is not a symbol name). That way you can eveen test if the conversion failed with:
$ IF (.NOT.$STATUS) THEN SAY "bad input"
Of course even better code would be to first test using F$TYPE(INPUT) and then convert it, but that is an extra step to add to the code.