= operation for a variable

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Post Reply
hariprasdkc
Member
Posts: 10
Joined: Fri May 08, 2009 11:55 am

= operation for a variable

Post by hariprasdkc » Fri Jun 05, 2009 2:24 pm

i have a variable

Code: Select all

01 VARIABLE1 PIC X(5) value 'OHIO'.
When i check VARIABLE1 like

Code: Select all

IF VARIABLE1 = 'OHIO'
See that VARIABLE1 is X(5)... n i have checked it with OHIO...
What will be the outcome? does it cause data or operation exception.?
Thanks in advance...

User avatar
Chanti
Member
Posts: 32
Joined: Thu Nov 27, 2008 4:31 pm

Post by Chanti » Fri Jun 05, 2009 3:32 pm

It doesn't give data/operation exception!!

Outcome -- The if condition is True

hariprasdkc
Member
Posts: 10
Joined: Fri May 08, 2009 11:55 am

Post by hariprasdkc » Fri Jun 05, 2009 3:40 pm

The if condition cant be true...?If am wrong plz correct me... like the variable is of X(5)... n so it must have value stored as 'OHIOb' (b is blank) n in the checking it is actually checkin like

Code: Select all

IF 'OHIO ' = 'OHIO' 
so by value it is not equal rite..then how can u say the IF condition outcome is TRUE..???? :mrgreen:

User avatar
Chanti
Member
Posts: 32
Joined: Thu Nov 27, 2008 4:31 pm

Post by Chanti » Fri Jun 05, 2009 4:02 pm

the if condition will be true for the following cases--

IF VARIABLE1 = 'OHIO' --- (this is becoz of initial VALUE)
or IF VARIABLE1 = 'OHIO '

hariprasdkc
Member
Posts: 10
Joined: Fri May 08, 2009 11:55 am

Post by hariprasdkc » Fri Jun 05, 2009 4:38 pm

:shock: then = operator is bugged??? conventionally 'OHIO' is not equal to 'OHIO ' na???..

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Fri Jun 05, 2009 6:52 pm

why don't y'all read the reference manual instead of guessing?
unequal size If the operands are of unequal size, the comparison is made as though the shorter operand were extended to the right with enough spaces to make the operands equal in size
above is extracted from the following Link

this is basic data processing concept. RTFM.....
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

hariprasdkc
Member
Posts: 10
Joined: Fri May 08, 2009 11:55 am

Post by hariprasdkc » Fri Jun 05, 2009 7:04 pm

Read the manual dino.. but couldnt recollect that...Neway..Thanks dude... :)

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others