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
 

 

Contest for the experts

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

New User


Joined: 09 Apr 2006
Posts: 20
Location: Chennai

PostPosted: Tue Apr 11, 2006 9:22 pm    Post subject: Contest for the experts
Reply with quote

I have declared two variables like this.

77 A PIC 9(4).
77 B PIC X(6).

I am moving the following values.

MOVE 9999 TO A.
MOVE 9999 TO B.

IF A = B
DISPLAY 'TRUE'
ELSE
DISPLAY 'FALSE'
END-IF


What will be displayed after executing the IF-LOOP? icon_biggrin.gif
Back to top
View user's profile Send private message

martin9

Active User


Joined: 01 Mar 2006
Posts: 288
Location: Basel, Switzerland

PostPosted: Tue Apr 11, 2006 9:32 pm    Post subject:
Reply with quote

hy kingofmainframes,

TRUE

martin9
Back to top
View user's profile Send private message
stalin.i@gmail.com

New User


Joined: 18 Apr 2005
Posts: 8
Location: chennai

PostPosted: Tue Apr 11, 2006 9:42 pm    Post subject:
Reply with quote

Hi King,

TRUE icon_biggrin.gif
Back to top
View user's profile Send private message
kingofmainframes
Warnings : 2

New User


Joined: 09 Apr 2006
Posts: 20
Location: Chennai

PostPosted: Tue Apr 11, 2006 9:46 pm    Post subject:
Reply with quote

Hello Martin , Stalin

Do you notice field B is defined with X(6) so it will effectively contain two blanks at end. whereas A will contain only "9999" ?

A = "9999"
B = "9999 "
Back to top
View user's profile Send private message
martin9

Active User


Joined: 01 Mar 2006
Posts: 288
Location: Basel, Switzerland

PostPosted: Tue Apr 11, 2006 10:37 pm    Post subject:
Reply with quote

hy kingofmainframes,

hex value is x'F9F9F9F9' for A
and x'F9F9F9F94040' for B.
therefore A is only 4 bytes,
testing will end after fourth byte.

but why do you test this not yourself?
with a simple program you can test all
field comparisons very easily....

martin9 icon_smile.gif
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Apr 11, 2006 11:21 pm    Post subject: Re: Contest for the experts
Reply with quote

kingofmainframes,

To be correct. With cobol option OPTIMIZE(STD), the generated code is:

MOVE 9999 TO A.
MOVE 9999 TO B.

DISPLAY 'TRUE'

The compiler doesn't generate the "IF" test. The only possable condition is "TRUE" so thats what it generates.

martin9,

If your post is correct then.

Quote:

77 A PIC 9(4).
77 B PIC X(6).

I am moving the following values.

MOVE 9999 TO A.
MOVE 99999 TO B.

IF A = B
DISPLAY 'TRUE'
ELSE
DISPLAY 'FALSE'
END-IF


would test "TRUE" , but it tests "FALSE"
Back to top
View user's profile Send private message
kingofmainframes
Warnings : 2

New User


Joined: 09 Apr 2006
Posts: 20
Location: Chennai

PostPosted: Wed Apr 12, 2006 11:14 pm    Post subject: Re: Contest for the experts
Reply with quote

Martin,

Thanks for your response. will get back to you soon.

DavidatK,

I got your point. Still why would the compiler option OPTIMIZE(STD) generate such a code?.

MOVE 9999 TO A.
MOVE 9999 TO B.

DISPLAY 'TRUE'




ok. In case if I code the program as follows, what will be the outcome of the test.


I have declared two variables like this.

77 A PIC 9(4).
77 B PIC X(6).
01 FILE01-REC
02 C PIC 9(4) COMP-3.
02 D PIC 9(6) COMP-3.
I am moving the following values.

READ FILE01 INTO FILE01-REC.

MOVE C TO A.
MOVE D TO B.

IF A = B
DISPLAY 'TRUE'
ELSE
DISPLAY 'FALSE'
END-IF

Assume C and D has 9999 as value. icon_biggrin.gif
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 Help Required from experts - Natural ... SCARCEBOYZ Java & MQSeries 2 Fri May 08, 2009 4:35 pm
This topic is locked: you cannot edit posts or make replies. CICS experts required in a Global IT ... saloni Mainframe Jobs 0 Sat Aug 23, 2008 5:37 pm
This topic is locked: you cannot edit posts or make replies. PL/1 experts required in a Global IT ... saloni Mainframe Jobs 0 Sat Aug 23, 2008 5:35 pm
No new posts Java , j2EE Openings for Bangalore it... Madhu_careers Mainframe Jobs 0 Fri Jun 15, 2007 4:50 pm
No new posts Onsite opportunity for Oracle apps Ex... siva_p543 Mainframe Jobs 0 Wed Jun 13, 2007 6:02 pm


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