Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

complex condition question.. 1

Status
Not open for further replies.

nxm150

Programmer
May 22, 2002
78
0
0
US
Is the following

IF FIELD-1 NOT = 'AB' AND 'CD'

the same as

IF FIELD-1 NOT = 'AB' AND NOT = 'CD'
 
You are asking if two abbreviated relational conditions are the same.

The effect of using such abbreviations is as if the last preceding stated subject were inserted in place of the omitted subject, and the last stated relational operator were inserted in place of the omitted relational operator.

The interpretation applied to the use of the word NOT in an abbreviated combined relation condition is:[ul square][li]If the word immediately following NOT is GREATER, >, LESS, <, EQUAL or =, the NOT participates as part of the relational operator.[/li][li]In all other circumstances, the NOT is interpreted as a logical operator and, therefore, the implied insertion of subject or relational operator results in a negated relation condition.[/li][/ul]

Since the word that follows NOT is =, the omitted relational operator is NOT =.

The non-abbreviated equivalent of
Code:
IF  FIELD-1 NOT = 'AB' AND 'CD'
is
Code:
IF  FIELD-1 NOT = 'AB' AND FIELD-1 NOT = 'CD'
because the omitted subject is FIELD-1 and the omitted relational operator is NOT =.

The non-abbreviated equivalent of
Code:
IF  FIELD-1 NOT = 'AB' AND NOT = 'CD'
is
Code:
IF  FIELD-1 NOT = 'AB' AND FIELD-1 NOT = 'CD'
because the omitted subject is FIELD-1 and the omitted relational operator is NOT =.

They look the same to me.

Tom Morrison
 
The short answer is Yes. I always wright it the first way.
 
I always use the long hand approach of
IF FIELD-1 NOT = 'AB'
AND FIELD-1 NOT = 'CD'

It takes not too many jots longer to code, and leaves no room for confusion.

Marc
 
I agree with MarcLodge. It's a lot easier to understand, especially for people with backgrounds in other languages (ie, Me), where it would make a difference.

-------------------------
Just call me Captain Awesome.
 
This is one of those "religious" topics :)

Other approaches I've seen (and I'll let you be the judge):
Code:
IF  NOT (FIELD-1 = 'AB' OR 'CD' ) 
   ...
END-IF
or
Code:
IF FIELD1 = 'AB' OR 'CD'
    CONTINUE
ELSE 
    ...
END-IF
or even
Code:
EVALUATE FIELD1
    WHEN 'AB'
    WHEN 'CD'
        CONTINUE
    WHEN OTHER
      ...
END-EVALUATE
Most folks I've talked with hate NOT logic and wouldn't recognize DeMorgan's Theorem if it bit them in the tush, so I suspect Option 2 would be most "popular", at least of these three.

GlennM (in deference to Glenn9999)
 
Thank you for the replies. Does anyone have a link (for documentation) to the above question.
 
Sure, you can go to the Liant web site, click on Product Documentation, and download the Language Reference Manual in PDF form. Search for the word 'abbreviated' and you should find it pretty easily.

Tom Morrison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top