|
|
| Author |
Message |
umanaga
New User
Joined: 09 Apr 2007 Posts: 3 Location: India
|
|
|
|
Will the below logic work fine
CODE 1:
01 WS-VAR1 PIC X VALUE '#'.
01 WS-VAR2 PIC X VALUE 'V'.
IF (WS-VAR1 > WS-VAR2)
DISPLAY 'I AM IN IF'
ELSE
DISPLAY 'I AM IN ELSE'
END-IF.
CODE 2:
IF( '#' > 'V' )
DISPLAY 'I AM IN IF'
ELSE
DISPLAY 'I AM IN ELSE'
END-IF.
Thanks in advance.  |
|
| Back to top |
|
 |
References
|
Posted: Sat Jun 07, 2008 7:46 am Post subject: Re: Comparing characters using COBOL |
 |
|
|
 |
yogeshwar_ade
Active User
Joined: 31 Aug 2006 Posts: 72 Location: INDIA
|
|
|
|
| Why Don't You Try and let us know the result? |
|
| Back to top |
|
 |
umanaga
New User
Joined: 09 Apr 2007 Posts: 3 Location: India
|
|
|
|
I tried CODE 2, but got compilation error. I havn't checked CODE 1.
Now i don't have access to mainframe.
So would like to hear from experts. |
|
| Back to top |
|
 |
yogeshwar_ade
Active User
Joined: 31 Aug 2006 Posts: 72 Location: INDIA
|
|
|
|
Your Code-1 will work & will give result as
It makes compare on equivalent EBCDIC collating sequence of '#' & 'V'.
Correct me If I am wrong.
Yogeshwar |
|
| Back to top |
|
 |
itdsen
New User
Joined: 20 Sep 2006 Posts: 17 Location: Chennai
|
|
|
|
Code 1 will work fine.
result : I Am In Else. |
|
| Back to top |
|
 |
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 498 Location: Richmond, Virginia
|
|
|
|
Are you going to tell us the compiler error?
Since the compiler can see what is being compared, it knows the result, and can therefore generate just the code needed. The remaining codce is dead and the compiler will issue a level 4 warning for it. |
|
| Back to top |
|
 |
|
|