Subject: | |
From: | |
Reply To: | |
Date: | Wed, 18 May 2005 13:23:16 -0700 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
01 TEXT PIC X(185).
01 TEXT-MAX PIC S9(4) COMP VALUE 185.
01 FX PIC S9(4) COMP.
01 TX PIC S9(4) COMP.
* where FX is "FROM-INDEX" and TX is "TO-INDEX".
MOVE 0 TO TX
PERFORM VARYING FX FROM 1 BY 1 UNTIL FX > TEXT-MAX
IF TEXT ( FX ) <> SPACE
AND TEXT ( FX + 1 ) <> SPACE
ADD 1 TO TX
MOVE TEXT ( FX ) TO TEXT ( TX )
END-IF
END-PERFORM
> -----Original Message-----
> From: Newton, Ernie [mailto:[log in to unmask]]
> Sent: Wednesday, May 18, 2005 11:31 AM
> To: [log in to unmask]
> Subject: COBOL question
>
> Greetings,
>
> I'm trying to take spaces out of the middle of a string.
>
> I cannot see the error in my logic.
>
> Here's what I'm doing...
>
> *************************************************
>
> PERFORM 2005-SQUISH-COMMENTS
> VARYING DL-COUNTER FROM 2
> BY 1 UNTIL DL-COUNTER > 186
>
> 2005-SQUISH-COMMENTS.
> COMPUTE LESS-1-COUNTER = DL-COUNTER - 1.
> IF COMMENT-BUFFER(LESS-1-COUNTER : 1) = SPACE
> AND COMMENT-BUFFER(DL-COUNTER : 1) = SPACE
> NEXT SENTENCE
> ELSE
> MOVE COMMENT-BUFFER(DL-COUNTER : 1)
> TO DL-COMMENTS(DL-COUNTER : 1)
>
> **************************************************
>
> DL-COMMENTS should be clean of extra spaces....shouldn't it?
>
> Is there an easier way using the STRING statement?
>
> Thanks,
>
> Ernie
>
> * To join/leave the list, search archives, change list settings, *
> * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
>
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|
|
|