View previous topic :: View next topic |
Author |
Message |
gpaulose Beginner
Joined: 04 Sep 2007 Posts: 10 Topics: 4
|
Posted: Wed Jan 16, 2008 12:05 pm Post subject: Remove trailing spaces from a variable in Cobol |
|
|
I need to remove trailing spaces from a variable in Cobol. Please suggest the easiest way of doing it. |
|
Back to top |
|
 |
CraigG Intermediate
Joined: 02 May 2007 Posts: 202 Topics: 0 Location: Viginia, USA
|
Posted: Wed Jan 16, 2008 12:31 pm Post subject: Re: Remove trailing spaces from a variable in Cobol |
|
|
gpaulose wrote: | I need to remove trailing spaces from a variable in Cobol. Please suggest the easiest way of doing it. |
What are you going to replace them with? |
|
Back to top |
|
 |
NASCAR9 Intermediate
Joined: 08 Oct 2004 Posts: 274 Topics: 52 Location: California
|
Posted: Wed Jan 16, 2008 12:42 pm Post subject: |
|
|
Code: |
01 W-TEXT PIC X(40) VALUE 'NAREN HAD PROBLEM'.
01 W-TALLY PIC S9(04) COMP VALUE ZERO.
01 W-STR-LENGTH PIC 9(03) VALUE ZERO.
PROCEDURE DIVISION.
MOVE ZEROES TO W-TALLY
W-STR-LENGTH.
INSPECT FUNCTION REVERSE(W-TEXT) TALLYING W-TALLY
FOR LEADING SPACES
COMPUTE W-STR-LENGTH = LENGTH OF W-TEXT - W-TALLY
DISPLAY 'THE STRING LENGTH IS:' W-STR-LENGTH
MOVE W_TEXT (1:W-STR-LENGTH) TO ??????
|
_________________ Thanks,
NASCAR9 |
|
Back to top |
|
 |
|
|