Re: append a string to another

From: Chuck Stevens (charles.stevens_at_unisys.com)
Date: 12/20/04


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.
>
>
>



Relevant Pages

  • [TOMOYO #15 3/8] Common functions for TOMOYO Linux.
    ... This file contains common functions (e.g. policy I/O, pattern matching). ... Since TOMOYO Linux is a name based access control, ... TOMOYO Linux's string manipulation functions make reviewers feel crazy, ... the Linux kernel accepts all characters but NUL character ...
    (Linux-Kernel)
  • RfD: Escaped Strings version 4
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... as an escape character for the entry of characters that cannot be ... \b BS (backspace, ASCII 8) ...
    (comp.lang.forth)
  • RfD: Escaped Strings version 4
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... as an escape character for the entry of characters that cannot be ... \b BS (backspace, ASCII 8) ...
    (comp.lang.forth)
  • Re: RfD: Escaped Strings
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... \b BS (backspace, ASCII 8) ... \ ** escapes to characters much as C does. ...
    (comp.lang.forth)
  • Re: A note on computing thugs and coding bums
    ... code is valid for any character set that is legal in C (which is a ... characters in the required source character set ... A String, in C Sharp or Java, can be redefined. ... allow programmers to handle some other data format, ...
    (comp.programming)