Re: Regarding EVALUATE TRUE
- From: "Pete Dashwood" <dashwood@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 17 Aug 2007 18:06:51 +1200
<klshafer@xxxxxxx> wrote in message
news:1187287125.160229.308750@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Aug 16, 12:40 pm, docdw...@xxxxxxxxx () wrote:
In article <1187279407.749229.171...@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
klsha...@xxxxxxx <klsha...@xxxxxxx> wrote:
EVALUATE TRUE
WHEN CASE-IN-COMPLETE
SET IN-COMPLETE-CASE TO TRUE
PERFORM 1000-SET-CASE-TYPE-MSG
WHEN NO-CASE-EXISTS
SET NON-EXISTING-CASE TO TRUE
PERFORM 1000-SET-CASE-TYPE-MSG
WHEN CASE-EXISTS-BUT-NOT-EXACT
SET NON-MATCHING-CASE TO TRUE
PERFORM C110-SET-CASE-TYPE-MSG
WHEN CASE-EXISTS-EXACTLY
* *** NOW PROCESS VERY GOOD CASE ACCORDING TO ITS STATUS...
Gah... with all due respect, Mr Shafer, I disagree with what follows...
for two reasons.
EVALUATE TRUE
WHEN WEA1CAS-STATUS = IND-TYPE-OF-CASE
CONTINUE
WHEN WEA1CAS-STATUS > SPACE
AND CASE-OPEN OF WEA1CAS-SACSTAT
PERFORM 2000-FINISH-CASE-EDIT-S
WHEN WEA1CAS-STATUS > SPACE
AND CASE-CLOSED OF WEA1CAS-CASE-STATUS
PERFORM 3000-FORMAT-WEA1CASA
PERFORM 4000-UPDATE-WEA1CASA-6CASH
WHEN WEA1CAS-STATUS = SPACE
AND CASE-OPEN OF WEA1CAS-CASE-STATUS
IF CASE--OPEN OF CSN-CASE-STATUS
PERFORM 3000-FORMAT-WEA1CASA
PERFORM 4000-UPDATE-WEA1CASA-6CASH
ELSE
CONTINUE
END-IF
WHEN OTHER
CONTINUE
First reason... no END-EVALUATE for the interior EVALUATE.
OK, my brain is not a very good compiler, but you already knew
that :-). So I know this first reason is not *really* what you are
talking about, is it?
Second
reason... for reasons that are readily and immediately apparent to anyone
of good, decent, sane and sound judgement - in other words, a matter of
Style and Aesthetics - I try to alternate IF and EVALUATE for interior
logic.
Ahhh, yes, the real reason - I enroached upon your easily offended
artistic sensibilities. Let me respond in my (hopefully) usual genteel
fashion...
Hmmmm... I think I have read elsewhere about the Virtue of Alternating
IF/EVALUATE; it is not an Original Idea of yours, is it? It is not a
matter that brings forth strong feelings on my part. I could certainly
adhere to any such directive; I could certainly adhere to one without
it :-).
But rather than digress into that matter, let me emphasize what may be
the not-too-obvious. You and I here are now discussing what is under
only _one leg_ of the outer-EVALUATE. And the leg in question has as
its given a condition of CASE-EXISTS-EXACTLY. This is of itself a
significant step forward from where we were before.
After all, all of the code you challenged could now be encapsulated
into its own paragraph, and the exterior becomes...
EVALUATE TRUE
WHEN CASE-IN-COMPLETE
SET IN-COMPLETE-CASE TO TRUE
PERFORM 1000-SET-CASE-TYPE-MSG
WHEN NO-CASE-EXISTS
SET NON-EXISTING-CASE TO TRUE
PERFORM 1000-SET-CASE-TYPE-MSG
WHEN CASE-EXISTS-BUT-NOT-EXACT
SET NON-MATCHING-CASE TO TRUE
PERFORM C110-SET-CASE-TYPE-MSG
WHEN CASE-EXISTS-EXACTLY
* *** NOW PROCESS VERY GOOD CASE ACCORDING TO ITS STATUS...
PERFORM 2000-PROCESS-EXACT-CASE
WHEN OTHER
DISPLAY "BAD INTERNAL ERROR IN " WS-CURRENT-PARAGRAPH
PERFORM 999-ABEND-EXIT
END-EVALUATE
See, now we need only discuss what 2000-PROCESS-EXACT-CASE should look
like. We have now scoped and bounded the problem area a bit.
As I have said (indirectly) to the client - you have your choice - I
can rewrite this subsystem all at once, or one defect fix at a time.
My goals are modest - just make it a little bit better a fix at a
time.
(by the bye.. this code does not give the same results when
(IND-TYPE-OF-CASE = SPACES AND CASE-OPEN OF WEA1CAS-CASE-STATUS),
either... but That Could Never Happen, right?
Ummmmm, yes indeed, this is some of the perils of the Booleans in the
condition. And under what circumstances is the WHEN OTHER satisfied?
Will Mr. Dashwood please step forward to apply his De Morgan's
Laws? :-)
Well, they're not MY laws, and, actually having a life that no longer
involves pedantic arguments about the infinitely stupid ways in which people
can and do write COBOL, you will understand my staying at the back of the
class on this, avoiding Teacher's gaze, just keeping one eye on it and one
ear half open, in the forlorn hope that there might be something amusing or
entertaining, and applying what feeble few brain cells I have left to
ensuring that "enterprises of great pitch and moment" do not, "with this
regard" have their "currents turn awry, and lose the name of action."
In other words, "I'm busy...", but, some here think that saying that (even
when it's true) is just a Management excuse for not doing something, and
being the insecure shrinking violet that I am, in desperate need of the
approval of CLC, I took a few moments to cast an eye over the redundant mess
you posted above.
The first thing that struck me is that it tests a condition and then sets
another condition...
WHEN CASE-IN-COMPLETE
SET IN-COMPLETE-CASE TO TRUE
.... and it does this on several occasions.
I suppose if you have a vested interest in hastening the heat death of the
Universe, this might be acceptable, but to me it is just nonsense. Normally,
I wouldn't waste time on it, (and would charge a serious sum of money if I
did) but since you asked, and since I have spent most of the morning
engrossed in real work and am in need of some light relief, (and I can't
find a cryptic crossword to refresh my thought processes), I have spent the
time instead, applying good old George's postulates and Augustus De
Morgan's extensions of them, to see if the yarn can be unravelled...
I believe the following valid COBOL could replace the EVALUATE above without
any loss of functionality:
IF NOT CASE-EXISTS-EXACTLY
IF NOT CASE-EXISTS-BUT-NOT-EXACT
PERFORM 1000-SET-CASE-TYPE-MSG
ELSE
PERFORM C110-SET-CASE-TYPE-MSG
END-IF
ELSE
IF NOT WEA1CAS-STATUS = IND-TYPE-OF-CASE
EVALUATE TRUE
WHEN WEA1CAS-STATUS > SPACE AND CASE-OPEN OF
WEA1CAS-SACSTAT
PERFORM 2000-FINISH-CASE-EDIT-S
WHEN (WEA1CAS-STATUS > SPACE AND CASE-CLOSED OF
WEA1CAS-CASE-STATUS) OR
(WEA1CAS-STATUS = SPACE AND CASE-OPEN
OF WEA1CAS-CASE-STATUS AND
CASE--OPEN OF CSN-CASE-STATUS)
PERFORM 3000-FORMAT-WEA1CASA
PERFORM 4000-UPDATE-WEA1CASA-6CASH
END-EVALUATE
END-IF
END-IF
It is around half of the original code.
It has had redundant tests and actions removed, does not need CONTINUE or
WHEN OTHER because these have been percolated to the bottom so they simply
fall off.
It does make the following assumptions:
1. There's no way I will code the setting of a flag based on a flag, so you
must consider the following to be logically equivalent:
CASE-IN-COMPLETE = IN-COMPLETE-CASE
NO-CASE-EXISTS = NON-EXISTING-CASE
CASE-EXISTS-BUT-NOT-EXACT = NON-MATCHING-CASE
(If it is a flag in a different record, then set ALL the flags in the record
immediately before you write it, using the single instance master flags in
WS. If it's NOT in a different record then do a global edit and replace
every reference to the right side of the equivaleneces above, replacing them
with the left side.Then remove the stupid SETs.).
2. The solution assumes that the Universe is what was posted. For example,
there are no other unreferenced 88s on the same flag as the ones described.
It is easy to amend the underlying Boolean truth table if there are, but for
this exercise, no...
3. I have not read previous posts in this thread (which might have different
code or discussion, or clarify or obfuscate the code above.) and the
solution is limited only to what is here. (See point 2, above).
No warranty is expressed or implied; I did this Simplification in my "tea
break" as a welcome relief from design logic problems. If it is wrong I'm
embarrassed and sorry, but don't expect any money :-) It has not been
subject to the QA that work which I normally do is put through.
As for your question, well, it is now pointless because there is no need for
WHEN OTHER. . However, for the sake of completeness, it would be the
negation of ALL of the conditions in ALL of the WHENs above it...
WHEN OTHER = IF NOT (all conditions in WHENs, parenthesized and ORed )
What was it you said earlier? Ahhh, yes, here it is...
"What should be considered the case when using a 'case' construct,
then, seems to be worthy of more than passing examination... LEFT-
HANDED does not rule out BROWN-EYED does not rule out HAS-SIX-TOES."
Er...it DOES sometimes....
01 SILLY-FLAG PIC X VALUE SPACE.
88 LEFT-HANDED VALUE '1'.
88 BROWN-EYED VALUE '2'.
88 HAS-SIX-TOES VALUE '3'.
I believe that you are right on target here. To do such a "more than
passing examination" does not seem to be a merely pedantic exercise to
me. Rather, I think it gets right to the Heart of the Matter.
Only as long as you realise that thinking in English is NOT the same as
thinking in COBOL...
Pete.
--
"I used to write COBOL...now I can do anything."
.
- Follow-Ups:
- Re: Regarding EVALUATE TRUE
- From: klshafer@xxxxxxx
- Re: Regarding EVALUATE TRUE
- References:
- Regarding EVALUATE TRUE
- From: klshafer@xxxxxxx
- Re: Regarding EVALUATE TRUE
- From: klshafer@xxxxxxx
- Re: Regarding EVALUATE TRUE
- From: Frank Swarbrick
- Re: Regarding EVALUATE TRUE
- From: klshafer@xxxxxxx
- Re: Regarding EVALUATE TRUE
- From:
- Re: Regarding EVALUATE TRUE
- From: klshafer@xxxxxxx
- Regarding EVALUATE TRUE
- Prev by Date: Re: field validation (was Re: COBOL/DB2 Date edit question)
- Next by Date: Re: field validation (was Re: COBOL/DB2 Date edit question)
- Previous by thread: Re: Regarding EVALUATE TRUE
- Next by thread: Re: Regarding EVALUATE TRUE
- Index(es):
Relevant Pages
|