Re: append a string to another
From: Chuck Stevens (charles.stevens_at_unisys.com)
Date: 12/20/04
- Next message: Richard: "Re: Email from JCL with attachment"
- Previous message: Bill Gentry: "Email from JCL with attachment"
- In reply to: JerryMouse: "Re: append a string to another"
- Next in thread: JJ: "Re: append a string to another"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 20 Dec 2004 14:52:53 -0800
I prefer INSPECT FUNCTION REVERSE for figuring out where the last non-blank
character is.
-Chuck Stevens
"JerryMouse" <nospam@bisusa.com> wrote in message
news:10sejuos7es0s1a@news.supernews.com...
> Tobias Neubert wrote:
> > Hi,
> >
> > I am a Cobol newby, trying to write a first program which reads in a
> > textfile, line by line and concatenates the lines to one big string. I
> > do the following:
> >
> > ------------
> > string thelongstring delimited by size
> > In-Data delimited by size
> > into thelongstring
> > ---------------
> >
> > thelongstring is 32000 bytes long, In-Data is 80 bytes long. It seems
> > that cobol appends In-Data at the very end of thelongstring, that is
> > after the last space at position 32000.
> >
> > Please tell me how it is possible to solve my problem.
>
> You need to know the length of the data contained in string-1, either
> implicitly or explicitly.
>
> Implicitly, as others have said,
> STRING string-1 DELIMITED BY " " .....
>
> For explicitly, you need to find the length. There are several ways:
>
> Method 1:
> PERFORM VARYING LEN FROM 32000 BY -1
> UNTIL string-1(LEN:1) NOT = SPACE
> CONTINUE
> END-PERFORM
>
> STRING string-1(1:LEN) DELIMITED SIZE....
>
> Method 2 (If compiler permits):
> COMPUTE LEN = FUNCTION STORED-CHAR-LENGTH(string-1)
>
> Method 3 (many fans)
> MOVE FUNCTION REVERSE(string-1) TO string-1
> MOVE 0 TO LEN
> INSPECT string-1 TALLYING LEN FOR LEADING SPACE
> COMPUTE LEN = 32000 - LEN
>
> Have fun.
>
>
>
- Next message: Richard: "Re: Email from JCL with attachment"
- Previous message: Bill Gentry: "Email from JCL with attachment"
- In reply to: JerryMouse: "Re: append a string to another"
- Next in thread: JJ: "Re: append a string to another"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|