<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Silly DCL question in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/silly-dcl-question/m-p/5138413#M44780</link>
    <description>Thanks, any more examples?</description>
    <pubDate>Thu, 30 Oct 2008 14:38:31 GMT</pubDate>
    <dc:creator>Jimson_1</dc:creator>
    <dc:date>2008-10-30T14:38:31Z</dc:date>
    <item>
      <title>Silly DCL question</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/silly-dcl-question/m-p/5138409#M44776</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Silly question here...&lt;BR /&gt;And all because I need to justify my review comments on some DCL script that someone changed...&lt;BR /&gt;&lt;BR /&gt;In DCL, why bother having the comparison operators .ne. and .nes. when DCL converts everything to the same type before the comparison anyway?&lt;BR /&gt;&lt;BR /&gt;For example, all the following work:&lt;BR /&gt;&lt;BR /&gt;$ IF 1 .EQS. "1" THEN WRITE SYS$OUTPUT "EQUAL"&lt;BR /&gt;EQUAL&lt;BR /&gt;&lt;BR /&gt;$ IF 1 .EQ. "1" THEN WRITE SYS$OUTPUT "EQUAL"&lt;BR /&gt;EQUAL&lt;BR /&gt;&lt;BR /&gt;$ IF "1" .EQ. 1 THEN WRITE SYS$OUTPUT "EQUAL"&lt;BR /&gt;EQUAL&lt;BR /&gt;&lt;BR /&gt;$ IF "1" .EQS. 1 THEN WRITE SYS$OUTPUT "EQUAL"&lt;BR /&gt;EQUAL&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Oct 2008 11:11:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/silly-dcl-question/m-p/5138409#M44776</guid>
      <dc:creator>Jimson_1</dc:creator>
      <dc:date>2008-10-30T11:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: Silly DCL question</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/silly-dcl-question/m-p/5138410#M44777</link>
      <description>Try &lt;BR /&gt;&lt;BR /&gt;$ IF 01 .EQ. "01" THEN WRITE SYS$OUTPUT "EQUAL"&lt;BR /&gt;&lt;BR /&gt;vs&lt;BR /&gt;&lt;BR /&gt;$ IF 01 .EQS. "01" THEN WRITE SYS$OUTPUT "EQUAL"&lt;BR /&gt;&lt;BR /&gt;hth,&lt;BR /&gt;Hein.</description>
      <pubDate>Thu, 30 Oct 2008 11:23:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/silly-dcl-question/m-p/5138410#M44777</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2008-10-30T11:23:54Z</dc:date>
    </item>
    <item>
      <title>Re: Silly DCL question</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/silly-dcl-question/m-p/5138411#M44778</link>
      <description>Excellent.&lt;BR /&gt;Thanks.&lt;BR /&gt;Unfortunately I can only give you 10 points.&lt;BR /&gt;You deserve twice as many.&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;JamesP</description>
      <pubDate>Thu, 30 Oct 2008 13:00:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/silly-dcl-question/m-p/5138411#M44778</guid>
      <dc:creator>Jimson_1</dc:creator>
      <dc:date>2008-10-30T13:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Silly DCL question</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/silly-dcl-question/m-p/5138412#M44779</link>
      <description>Another example showing what can happen if you use the wrong comparison operator:&lt;BR /&gt;&lt;BR /&gt;$ IF "abcdef" .eq. "GHIJKL" THEN WRITE SYS$OUTPUT "same string"&lt;BR /&gt;same string&lt;BR /&gt;</description>
      <pubDate>Thu, 30 Oct 2008 14:32:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/silly-dcl-question/m-p/5138412#M44779</guid>
      <dc:creator>Jess Goodman</dc:creator>
      <dc:date>2008-10-30T14:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: Silly DCL question</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/silly-dcl-question/m-p/5138413#M44780</link>
      <description>Thanks, any more examples?</description>
      <pubDate>Thu, 30 Oct 2008 14:38:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/silly-dcl-question/m-p/5138413#M44780</guid>
      <dc:creator>Jimson_1</dc:creator>
      <dc:date>2008-10-30T14:38:31Z</dc:date>
    </item>
    <item>
      <title>Re: Silly DCL question</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/silly-dcl-question/m-p/5138414#M44781</link>
      <description>JamesP,&lt;BR /&gt;&lt;BR /&gt;  Not a silly question at all!&lt;BR /&gt;&lt;BR /&gt;  Jess's example shows a very common error in DCL code. I've been bitten by that one many times! &lt;BR /&gt;&lt;BR /&gt;"when DCL converts everything to the same type before the comparison anyway?"&lt;BR /&gt;&lt;BR /&gt;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:&lt;BR /&gt;&lt;BR /&gt;$ x=1&lt;BR /&gt;$ s1="A"&lt;BR /&gt;$ s2="B"&lt;BR /&gt;$ s3=s1+s2&lt;BR /&gt;$ s4=s1+s2+x&lt;BR /&gt;&lt;BR /&gt;  The presence of a single numeric symbol changes the whole expression to numeric, so the value of s4 is (numeric) 1.&lt;BR /&gt;&lt;BR /&gt;  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.</description>
      <pubDate>Fri, 31 Oct 2008 01:15:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/silly-dcl-question/m-p/5138414#M44781</guid>
      <dc:creator>John Gillings</dc:creator>
      <dc:date>2008-10-31T01:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: Silly DCL question</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/silly-dcl-question/m-p/5138415#M44782</link>
      <description>&lt;!--!*#--&gt;John,&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;Just like an implicit conversion, F$INTEGER converts non-numeric strings to either 0 or 1 based on the first character.&lt;BR /&gt;&lt;BR /&gt;So instead of code like this:&lt;BR /&gt;$ I = F$INTEGER(INPUT)&lt;BR /&gt;&lt;BR /&gt;I use:&lt;BR /&gt;$ I = 'INPUT'&lt;BR /&gt;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:&lt;BR /&gt;$ IF (.NOT.$STATUS) THEN SAY "bad input"&lt;BR /&gt;&lt;BR /&gt;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.</description>
      <pubDate>Fri, 31 Oct 2008 14:36:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/silly-dcl-question/m-p/5138415#M44782</guid>
      <dc:creator>Jess Goodman</dc:creator>
      <dc:date>2008-10-31T14:36:15Z</dc:date>
    </item>
  </channel>
</rss>

