Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

COBOL ABBREVIATED CONDITION
I'm reading COBOL program and can't make sure the meaning of the following
abbreviated condition:

If A NOT = B AND NOT C

Is it equivalent to

If A NOT = B AND A = C

or

If A NOT = B AND A NOT = C   ???



Thanks in advance.



Thomas Li





Report this thread to moderator Post Follow-up to this message
Old Post
Thomas A. Li
06-17-04 01:55 AM


Re: COBOL ABBREVIATED CONDITION
Thomas A. Li <tli@corporola.com> wrote in message news:SN1Ac.4490$7C%1.498@news04.bloor.is.
net.cable.rogers.com...
> I'm reading COBOL program and can't make sure the meaning of the following
> abbreviated condition:
>
> If A NOT = B AND NOT C
>
> Is it equivalent to
>
> If A NOT = B AND A = C

No

>
> or
>
> If A NOT = B AND A NOT = C   ???

Yes


Now try

IF  NOT A = B OR C

This ambiguity should convince you NOT to use abbreviation.  It can be fatal
.



Report this thread to moderator Post Follow-up to this message
Old Post
Hugh Candlin
06-17-04 01:55 AM


Re: COBOL ABBREVIATED CONDITION
On 16-Jun-2004, "Thomas A. Li" <tli@corporola.com> wrote:

> I'm reading COBOL program and can't make sure the meaning of the following
> abbreviated condition:

Remember this.   If the code isn't obvious, then the programmer should have 
made
it obvious.   That's a major feature of good CoBOL design.


> If A NOT = B AND NOT C
>
> Is it equivalent to
>
> If A NOT = B AND A = C
>
> or
>
> If A NOT = B AND A NOT = C   ???

See if this link helps:
http://publibz.boulder.ibm.com/cgi-...927030801&CASE=


Unless modified by parentheses, the following precedence rules (from
highest to lowest) apply:



Arithmetic operations
Simple conditions
NOT
AND
OR

Report this thread to moderator Post Follow-up to this message
Old Post
Howard Brazee
06-17-04 01:55 AM


Re: COBOL ABBREVIATED CONDITION
Nope... try it... these are all true.


identification division.
program-id. testit.
environment division.
working-storage section.
01  .
05 A    pic 9 value 1.
05 B    pic 9 value 2.
05 C    pic 9 value 1.
procedure division.
000-main.
if A not = B and not C
display 'True'.
if not A = B or C
display 'True'.
if A not = B and A = C
display 'True'.
goback.



Report this thread to moderator Post Follow-up to this message
Old Post
Mike
06-17-04 01:55 AM


Re: COBOL ABBREVIATED CONDITION
All three standards have an example of an Abbreviated Combined Relation
Condition that can be used to figure this out definitively.  This example
appears in ISO/IEC 1989:2002 on Page 137; in ANSI X3.23-1985 on Page VI-61;
and in ANSI X3.23-1974 on Page II-48.

This example is the last in a group of Abbreviated Combined Relation
Condition examples:
NOT (a NOT > b AND c AND NOT d)
and it is explicitly described as equivalent to
NOT ((((a NOT > b) AND (a NOT > c)) AND (NOT (a NOT > d))))

As I see it:

Dropping the outer NOT, this becomes:
a NOT > b AND c AND NOT d
which is interpreted as
(((a NOT > b) AND (a NOT > c)) AND (NOT (a NOT > d )))

Dropping the inner "AND c", we get
a NOT > b AND NOT d
which is interpreted as
((a NOT > b) AND (NOT (a NOT > d)))

Now, making the appropriate operator and letter substitutions in the
example,
A NOT = B AND NOT C
is correctly interpreted as
(A NOT = B) AND (NOT (A NOT = C)).

Because "NOT (A NOT = C) is the same as "A = C" in this case, the original
IF becomes
IF (A NOT = B) AND (A = C) ...
which is, of course.
IF A NOT = B AND A = C ...

Many people assume that abbreviation implies some sort of override of the
normal precedence rules that doesn't apply when the full specification
(without parentheses) is used.  'T'aint so.   "NOT =" is a *simple*
relational operator in 2002-speak.  "NOT [implied subject] [implied
relational] C" is "NOT (A NOT = C)" when [implied subject] is "A" and
[implied relational] is "NOT =".

Lest anyone misunderstand:  I Do Not Like Abbreviated Combined Relation
Conditions.

The 2002 standard warns, just before the examples of abbreviated combined
relation conditions:   "NOTE  The use of NOT often leads to results that are
not intuitive and therefore it should be avoided."

-Chuck Stevens

"Thomas A. Li" <tli@corporola.com> wrote in message
news:SN1Ac.4490$7C%1.498@news04.bloor.is.net.cable.rogers.com...
> I'm reading COBOL program and can't make sure the meaning of the following
> abbreviated condition:
>
> If A NOT = B AND NOT C
>
> Is it equivalent to
>
> If A NOT = B AND A = C
>
> or
>
> If A NOT = B AND A NOT = C   ???
>
>
>
> Thanks in advance.
>
>
>
> Thomas Li
>
>
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Chuck Stevens
06-17-04 01:55 AM


Re: COBOL ABBREVIATED CONDITION
Well you could also interpret it this way:

if (value 1 not = value 2) and
(not condition c)

We have programs that are doing something like:

if (field 1 not = field 2) and
(not print-detail)
do procedure
end-if.

How that may be interpreted is you are doing a variable comparison and you
are checking for false condition.  Usually with an 88 level condition you
are checking for true or a true condition but in the statement above you are
checking for a false condition.  I was dealing with a program statement
similar to this last w.


"Thomas A. Li" <tli@corporola.com> wrote in message
news:SN1Ac.4490$7C%1.498@news04.bloor.is.net.cable.rogers.com...
> I'm reading COBOL program and can't make sure the meaning of the following
> abbreviated condition:
>
> If A NOT = B AND NOT C
>
> Is it equivalent to
>
> If A NOT = B AND A = C
>
> or
>
> If A NOT = B AND A NOT = C   ???
>
>
>
> Thanks in advance.
>
>
>
> Thomas Li
>
>
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Charles W. Cribbs II
06-17-04 01:55 AM


Re: COBOL ABBREVIATED CONDITION
"Chuck Stevens" <charles.stevens@unisys.com> wrote

> "NOTE  The use of NOT often leads to results that are
> not intuitive and therefore it should be avoided."

I am not quite understanding that, does it mean ?:

NOT ( intuitive and therefore it should be avoided )

->  ( NOT intuitive ) OR ( should NOT be avoided )

Report this thread to moderator Post Follow-up to this message
Old Post
Richard
06-17-04 08:55 AM


Re: COBOL ABBREVIATED CONDITION
"Chuck Stevens" <charles.stevens@unisys.com> wrote:

>The 2002 standard warns, just before the examples of abbreviated combined
>relation conditions:   "NOTE  The use of NOT often leads to results that ar
e
>not intuitive and therefore it should be avoided."

One of the Great Problems in programming is that intuition is fails us on lo
gic
problems even slightly complex, especially when they include NOT.

People who argue for 'the best tool for the job' ignore their own advice whe
n
they stubbornly try to handle such problems with Common Sense and refuse to
learn Boolean Algebra.

If we are going to spend our lives dealing with logic problems, it seems
reasonable to expect the necessary skills. Conversational English is simply
inadequate.


Report this thread to moderator Post Follow-up to this message
Old Post
Robert Wagner
06-17-04 01:55 PM


Re: COBOL ABBREVIATED CONDITION
So long as you use parentheses to establish the relation conditions and to
define their precedence, that's not a problem.  The issue is the
sometimes-counterintuitive rules surrounding NOT in an *abbreviated combined
relation condition* in combination with the fact that abbreviation does not
impact precedence at all.  It is in the smaller context of abbreviated
conditions that the suggestion to avoid NOT is made in the 2002 standard.

-Chuck Stevens


"Charles W. Cribbs II" <charlescribbs@earthlink.net> wrote in message
news:Ip5Ac.13505$Y3.100@newsread2.news.atl.earthlink.net...
> Well you could also interpret it this way:
>
> if (value 1 not = value 2) and
>    (not condition c)
>
> We have programs that are doing something like:
>
> if (field 1 not = field 2) and
>    (not print-detail)
>    do procedure
> end-if.
>
> How that may be interpreted is you are doing a variable comparison and you
> are checking for false condition.  Usually with an 88 level condition you
> are checking for true or a true condition but in the statement above you
are
> checking for a false condition.  I was dealing with a program statement
> similar to this last w.
>
>
> "Thomas A. Li" <tli@corporola.com> wrote in message
> news:SN1Ac.4490$7C%1.498@news04.bloor.is.net.cable.rogers.com... 
following 
>
>



Report this thread to moderator Post Follow-up to this message
Old Post
Chuck Stevens
06-17-04 08:55 PM


Re: COBOL ABBREVIATED CONDITION
Thomas A. Li wrote:
> I'm reading COBOL program and can't make sure the meaning of the following
> abbreviated condition:
>
> If A NOT = B AND NOT C

Is this an abbreviated condition?  It looks like "C" is a condition
name, not another variable with a value.  It's missing the "=" between
"NOT" and "C".

> Is it equivalent to
>
> If A NOT = B AND A = C
>
> or
>
> If A NOT = B AND A NOT = C   ???

So, if my above premise is true, no, they are not equivalent.  If it
said something like

If A NOT = B AND C

then your restatement #2 above would be equivalent.


--
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
~   /   \  /         ~        Live from Montgomery, AL!       ~
~  /     \/       o  ~                                        ~
~ /      /\   -   |  ~          LXi0007@Netscape.net          ~
~ _____ /  \      |  ~ http://www.knology.net/~mopsmom/daniel ~
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~         I do not read e-mail at the above address           ~
~    Please see website if you wish to contact me privately   ~
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~


Report this thread to moderator Post Follow-up to this message
Old Post
LX-i
06-27-04 08:55 AM


Sponsored Links




Last Thread Next Thread Next
Pages (2): [1] 2 »
Search this forum -> 
Post New Thread

Cobol archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 08:20 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.