Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Comparing characters using COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
umanaga

New User


Joined: 09 Apr 2007
Posts: 33
Location: India

PostPosted: Sat Jun 07, 2008 7:46 am    Post subject: Comparing characters using COBOL
Reply with quote

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. icon_smile.gif
Back to top
View user's profile Send private message

yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Sat Jun 07, 2008 7:50 am    Post subject: Reply to: Comparing character
Reply with quote

Why Don't You Try and let us know the result?
Back to top
View user's profile Send private message
umanaga

New User


Joined: 09 Apr 2007
Posts: 33
Location: India

PostPosted: Sat Jun 07, 2008 7:54 am    Post subject: Reply to: Comparing character
Reply with quote

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
View user's profile Send private message
yogeshwar_ade

Active User


Joined: 31 Aug 2006
Posts: 103
Location: INDIA

PostPosted: Sat Jun 07, 2008 8:56 am    Post subject: Reply to: Comparing character
Reply with quote

Your Code-1 will work & will give result as

Code:

I AM IN ELSE



It makes compare on equivalent EBCDIC collating sequence of '#' & 'V'.

Correct me If I am wrong.

Yogeshwar
Back to top
View user's profile Send private message
itdsen

New User


Joined: 20 Sep 2006
Posts: 23
Location: Chennai

PostPosted: Wed Jun 11, 2008 6:51 pm    Post subject: Reply to: Comparing characters using COBOL
Reply with quote

Code 1 will work fine.

result : I Am In Else.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 964
Location: Richmond, Virginia

PostPosted: Thu Jun 12, 2008 5:56 pm    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm
No new posts COBOL DB2 program - zIIP eligible vasanthz COBOL Programming 7 Wed May 31, 2017 5:12 am
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us