View previous topic :: View next topic
|
Author |
Message |
arunmozhicholan
New User
Joined: 07 Feb 2007 Posts: 27 Location: chennai
|
|
|
|
Code: |
If ((S-DATE1 = WS-START-DATE1 AND
WS-S-TIME < WS-START-TIME(IDX)) OR
(S-DATE1 = WS-END-DATE1 AND
WS-S-TIME > WS-END-TIME(IDX)) OR
(S-DATE1 < WS-START-DATE1 OR
S-DATE1 > WS-END-DATE1) OR
(S-DATE1 > WS-START-DATE1 AND
S-DATE1 <> WS-END-DATE1) OR
(S-DATE1 <> WS-START-DATE1 AND
S-DATE1 < WS-END-DATE1)) |
A literal or an expression was expected following a relational operator, but '>' was found , th if statement was discarded.
Please help me to get this done |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Please use the Code tags.
Where did you find "<>" in the Enterprise Cobol manual? |
|
Back to top |
|
|
arunmozhicholan
New User
Joined: 07 Feb 2007 Posts: 27 Location: chennai
|
|
|
|
Need to use not equal to ...? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Well, yes.
You have yourself an unreadable IF as well. You need to do some work to improve it. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Are there no other COBOL programs at your company to review? |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Years ago, when I did code review, I would hand this back to you and have you redo it.
There were times that in order to understand similar code, I'd have to generate the Assembler expansion, which occasionally ended in multiple right parenthesis.
You need to think of the next person who may need to do maintenance on this spaghetti salad.
What about EVALUATE or nested IF's?
Software Engineer's shouldn't be writing crap like this.... |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Code: |
.
.
.
S-DATE1 <> WS-END-DATE1) OR
. |
That's not how you use "NOT EQUAL TO" in COBOL. For COBOL it's
Code: |
IF A NOT EQUAL B THEN |
. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Code: |
IF (
(
( S-DATE1 EQUAL TO WS-START-DATE1 )
AND ( WS-S-TIME LESS THAN WS-START-TIME ( IDX ) )
)
OR (
( S-DATE1 EQUAL TO WS-END-DATE1 )
AND ( WS-S-TIME GREATER THAN WS-END-TIME ( IDX ) )
)
OR (
( S-DATE1 LESS THAN WS-START-DATE1 )
OR ( S-DATE1 GREATER THAN WS-END-DATE1 )
)
OR (
( S-DATE1 GREATER THAN WS-START-DATE1 )
AND ( S-DATE1 NOT EQUAL TO WS-END-DATE1 )
)
OR (
( S-DATE1 NOT EQUAL TO WS-START-DATE1 )
AND ( S-DATE1 LESS THAN WS-END-DATE1 )
)
) |
Even after "tarting it up" it is still very clumsy. Take some of Mr Bill's good advice. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Kept the thread open longer than anticiapted and missed the excellent suggestion from Bill O'Boyle. Read his post and try to implement. |
|
Back to top |
|
|
Ed Goodman
Active Member
Joined: 08 Jun 2011 Posts: 556 Location: USA
|
|
|
|
Been coding several decades. My weakest skill is working with date checking statements just like this one. I think they cause more confusion than any other type of condition checking.
I will spend two hours breaking them into nested IFs or Evaluate statements. usually when I'm done, I find that there is a much smaller way to do it. It's like factoring a large equation, then letting things cancel out. |
|
Back to top |
|
|
|