View previous topic :: View next topic
|
Author |
Message |
Prachi Mule
New User
Joined: 11 Aug 2011 Posts: 3 Location: India
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Prachi Mule
New User
Joined: 11 Aug 2011 Posts: 3 Location: India
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Prachi Mule
New User
Joined: 11 Aug 2011 Posts: 3 Location: India
|
|
|
|
Oh ok.
Thanks a lot! |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|