View previous topic :: View next topic
|
Author |
Message |
sri.mainframes
New User
Joined: 16 Feb 2006 Posts: 29 Location: MUMBAI
|
|
|
|
two data items A and B
A PIC A(5) VALUE 'S123S'
B PIC A(5) VALUE 'S123S'
CAN I DIRECTLY COMPARE LIKE
IF A = B
MOVE SPACES TO B.
ELSE MOVE A TO B.
CAN ANYONE FIND OUT WEATHER THE ABOVE CODE CORRECT OR NOT . IF NOT THEN HOW CAN I COMPARE TWO DATA ITEMS WITH '=' OPERTOR
thanks in advance
sri.prince |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
The answer to your question is yes, this is the way to do it.
BUT
you defined your areas as PIC A(5). As such, they can contain only alphabetic characters or spaces (no numbers).
Most programmers would use PIC X(5) which allows more freedom.
ALSO
The dot (.) before the ELSE should be removed.
Personnaly, I prefer to use END-IF over a final dot.
Very Important: Use indentation. Like this you can immediately see where the IF ends, when the ELSE starts and so on...
Code: |
IF A = B THEN
MOVE SPACES TO B
ELSE
MOVE A TO B
END-IF |
|
|
Back to top |
|
|
crrindia
Active User
Joined: 02 Jul 2005 Posts: 124 Location: Gurgaon
|
|
|
|
Hi Marso, I see in your sample code you have coded like shown below.
IF A = B THEN
MOVE SPACES TO B
ELSE
MOVE A TO B
END-IF[/code][/quote]
I think you have to code THEN instead of THAN. If I am wrong please excuse me. The correct code I am thinking is
IF A = B THAN
MOVE SPACES TO B
ELSE
MOVE A TO B
END-IF[/code][/quote]
Thanks!
Rat.. |
|
Back to top |
|
|
|