View previous topic :: View next topic |
Author |
Message |
s_shivaraj Beginner

Joined: 21 Sep 2004 Posts: 140 Topics: 14 Location: Chennai, India
|
Posted: Sat Jul 09, 2005 2:32 pm Post subject: Evaluate Condition |
|
|
Hi all,
Code: |
10 STATUS PIC X(2)
.
.
.
MOVE 'E ' TO STATUS
.
.
.
EVALUATE STATUS
WHEN SPACES
ADD 1 TO CNT
END-ADD
WHEN 'E'
CONTINUE
WHEN OTHER
DISPLAY '*** ERROR READING INPUT FILE ***' |
This codes works perfectly fine....
Here in the Evaluate status variable is checked with only a single byte 'E', althought it is a 2 byte variable holding value 'E '. I hope 'E' NOT equal to 'E '.
Even when the value of the variable is 'E ' its working perfectly fine...
Surprised to see how this code works.. it will be great if some one can throw light on this... _________________ Cheers
Sivaraj S
'Technical Skill is the Master of complexity, while Creativity is the Master of Simplicity' |
|
Back to top |
|
 |
Kathi Beginner

Joined: 14 May 2003 Posts: 25 Topics: 0 Location: Mission Viejo, California
|
Posted: Sat Jul 09, 2005 4:58 pm Post subject: |
|
|
See the rules of character movement and padding. See also the rules for comparing values when their lengths are different.
I'd also rethink your closing quote if you don't understand the question you asked. |
|
Back to top |
|
 |
s_shivaraj Beginner

Joined: 21 Sep 2004 Posts: 140 Topics: 14 Location: Chennai, India
|
Posted: Sat Jul 09, 2005 11:21 pm Post subject: |
|
|
Hi Kathi,
Could you please provide me some Links to check the same.. Thanks in advance _________________ Cheers
Sivaraj S
'Technical Skill is the Master of complexity, while Creativity is the Master of Simplicity' |
|
Back to top |
|
 |
s_shivaraj Beginner

Joined: 21 Sep 2004 Posts: 140 Topics: 14 Location: Chennai, India
|
Posted: Sun Jul 10, 2005 3:44 pm Post subject: |
|
|
Hi Kathi,
Thanks for your clarrification...I got the my query clarrified...
Quote: | String comparison is performed whenever numeric comparison is
inappropriate. Comparison of strings whose lengths differ may be
performed in two ways:
- The longer string may be truncated to the length of the shorter
prior to comparison (TRUNCATE parameter).
- The shorter string may be padded to the length of the longer prior
to comparison (PAD parameter). The character used for padding may
be explicitly specified. If it is not, an EBCDIC blank (X'40') is
used for data described as CHARACTER data or data described
using a general value of types C or T. If the data was described
using a general value associated with ISO-8 ASCII CHARACTER data
(types Q or S), padding is performed using an ISO-8 ASCII blank
(X'20'). Padding with a null character (X'00') is used for all
other types of data. |
_________________ Cheers
Sivaraj S
'Technical Skill is the Master of complexity, while Creativity is the Master of Simplicity' |
|
Back to top |
|
 |
neilxt Beginner
Joined: 01 Mar 2004 Posts: 23 Topics: 1
|
Posted: Wed Sep 20, 2006 8:24 am Post subject: Re: Evaluate Condition |
|
|
s_shivaraj wrote: | Hi all,
This codes works perfectly fine....
Here in the Evaluate status variable is checked with only a single byte 'E', althought it is a 2 byte variable holding value 'E '. I hope 'E' NOT equal to 'E '.
Even when the value of the variable is 'E ' its working perfectly fine...
Surprised to see how this code works.. it will be great if some one can throw light on this... |
Allow me to shine some historical perspective.
Mainframe business languages in general and COBOL in particular have always been designed on the principle that the main unit of work is the Record consisting of a number of related data items which could be addressed by their position within a Record Layout and which were therefore fixed length.
So mainframe languages were always designed to treat different length character fields as if the shorter were padded to the length of the larger with spaces. Neil is always Neil no matter what size field you store his name in.
PC languages started with the Variable as the unit of work. Character strings were always variable length because storage was at a premium and there was no value to be gained by having fixed length fields.
So PC languages started their comparison by checking the length. It was the most efficient way to spot discrepancies. So PC languages have always tended to treat 'Neil' as being different from 'Neil '.
Both methods have their advantages however from a business POV I'd say the former is probably preferable to the latter. |
|
Back to top |
|
 |
Cogito-Ergo-Sum Advanced
Joined: 15 Dec 2002 Posts: 637 Topics: 43 Location: Bengaluru, INDIA
|
Posted: Wed Sep 20, 2006 11:24 am Post subject: |
|
|
Your question is answered. Try EVALUATE STATUS (1:1) as a separate testcase and see what happens....  _________________ ALL opinions are welcome.
Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes. |
|
Back to top |
|
 |
|
|