Concat array elements into a string



Hi,
This seems straightforward but I can't seem to figure it out.
Basically, I have a table of elements and I want to string them all
together into a single text variable.

Here is the pseudocode

txtvar PIC X(30)
arrayvar [10]
do varying index from 1 by 1
txtvar = Rtrim(txtvar) || arrayvar(index) where || represents a
concatenation operator
until index = 10

I tried something like this in COBOL

perform varying ws-counter from 1 by 1 until ws-counter = 10
string txtvar ',' arrayvar(ws-counter)
delimited by size into txtvar
end-perform

But I just got spaces in txtvar at the end of it, presumably because I
don't have a trim function that I can use in COBOL (or is there one
that I just don't know of?)

I searched this forum and the web too on things like
"string array elements together" and didn't find anything useful.

Any ideas?

.



Relevant Pages

  • Re: Concat array elements into a string
    ... I have a table of elements and I want to string them all ... txtvar PIC X ... I tried something like this in COBOL ...
    (comp.lang.cobol)
  • Re: Concat array elements into a string
    ... I have a table of elements and I want to string them all ... txtvar PIC X ... need to use a delimiting character or perhaps " " (two spaces. ... INTO TXTVAR WITH POINTER TXTPOINT ...
    (comp.lang.cobol)
  • Re: Concat array elements into a string
    ... need to use a delimiting character or perhaps " " (two spaces. ... Note I removed txtvar from the string ... MOVE SPACES TO TXTVAR ... INTO TXTVAR WITH POINTER TXTPOINT ...
    (comp.lang.cobol)
  • Re: [OT] My First C# (warning - long post)
    ... cut me some slack - show me a COBOL program with less than 15 working-storage variables! ... Yes, the Trimis probably extra now, but that was my attempt to get it to quit griping at me that I had given it a "String", when it wanted a "char". ... public string IBreturn ...
    (comp.lang.cobol)
  • Re: [OT] My First C# (warning - long post)
    ... cut me some slack - show me a COBOL program with less than 15 ... string,. ... Here's a sample from live code that covers Casting string to Char, ... public string IBreturn ...
    (comp.lang.cobol)