IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Evaluate true also true


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Prachi Mule

New User


Joined: 11 Aug 2011
Posts: 3
Location: India

PostPosted: Thu Aug 11, 2011 7:43 pm
Reply with quote

Hi All,

I would like to know if there is any rule which says the in EVALUATE TRUE ALSO TRUE we cannot check more than one condition in teh also cause.

We have the following example in our code :
EVALUATE TRUE ALSO TRUE

WHEN STATE = 000 ALSO
(BRANCH = 123 OR BRANCH = 456)

In all of the evaluate statements we have the same convention.

Please let me know if this is a style of writing or a rule
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Aug 11, 2011 7:56 pm
Reply with quote

you could set-up a lvl-88 branch-is-123-456 values 123, 456

then the evaluate would be
WHEN STATE = 000 ALSO BRANCH-IS-123-456

either will work, it is allowed - it follows the rules as dictated by the cobol manual (actually compiler).

now,
is it a 'rule' or 'style of writing', depends on your site - your site creates a style based on site rules.
Back to top
View user's profile Send private message
Prachi Mule

New User


Joined: 11 Aug 2011
Posts: 3
Location: India

PostPosted: Thu Aug 11, 2011 7:59 pm
Reply with quote

So I can add a third branch in the ALSO clause

Like :

WHEN STATE = 000 ALSO
(BRANCH = 123 OR BRANCH = 456 OR BRANCH = 789)

right??
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Aug 11, 2011 8:02 pm
Reply with quote

I think section 6.2.13 of the COBOL Language Reference manual explains it:
Quote:
Operands before
the WHEN phrase Are interpreted in one of two ways, depending on how they are specified:

Individually, they are called selection subjects.

Collectively, they are called a set of selection subjects.

Operands in
the WHEN phrase Are interpreted in one of two ways, depending on how they are specified:

Individually, they are called selection objects

Collectively, they are called a set of selection objects.

ALSO
Separates selection subjects within a set of selection subjects; separates selection objects within a set of selection objects.

THROUGH and
THRU Are equivalent.

Two operands connected by a THRU phrase must be of the same class. The two operands thus connected constitute a single selection object.

The number of selection objects within each set of selection objects must be equal to the number of selection subjects.
Your example compiles and tests just fine -- as long as you have two selection subjects, and two selection objects, the logic can be pretty much whatever you want.
Back to top
View user's profile Send private message
Prachi Mule

New User


Joined: 11 Aug 2011
Posts: 3
Location: India

PostPosted: Thu Aug 11, 2011 8:04 pm
Reply with quote

Oh ok.
Thanks a lot!
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Aug 11, 2011 9:34 pm
Reply with quote

Another option is to use multiple WHEN:
Code:
WHEN STATE = 000 ALSO BRANCH = 123
WHEN STATE = 000 ALSO BRANCH = 456
WHEN STATE = 000 ALSO BRANCH = 789
    PERFORM BRANCH-IS-123-456-789
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Thu Aug 11, 2011 10:02 pm
Reply with quote

Prachi Mule wrote:
So I can add a third branch in the ALSO clause

Like :

WHEN STATE = 000 ALSO
(BRANCH = 123 OR BRANCH = 456 OR BRANCH = 789)

right??


If you do it with an 88-level, then you can have as many as you want without causing any confusion or increased complexity.

You can also do you ( STATE = 000 ) as an 88. Much nicer when you know that there is only one thing a literal relates to (the VALUE clause on an 88).

Code:
WHEN STATE-IS-HOME-STATE
  ALSO BRANCH-IS-HEAD-OFFICE-OR-STAFF-SALES


See how much more meaningful? OK, I've made the names up, but you see how it helps. If STATE is a geographical thing, then you wonder if both tests are necessary. A BRANCH can only be in one physical place, at least usually... Not so easy to think that when they are just a bunch of numbers.

By the way, I'd suggest not to use single words for data-names, especially ones which could so easily become "reserved" (by the Compiler) in the future.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Evaluate variable to execute a jcl step JCL & VSAM 3
No new posts Evaluate statement, when-clause in co... COBOL Programming 10
No new posts Generate report with out using IF/EVA... COBOL Programming 25
This topic is locked: you cannot edit posts or make replies. Want to put in a loop in EVALUATE COBOL Programming 24
Search our Forums:

Back to Top