Re: Concat array elements into a string



On Apr 19, 4:06 pm, Richard <rip...@xxxxxxxxxxxx> wrote:
On Apr 20, 6:53 am, charles.levi...@xxxxxxxxx wrote:




When you use 'delimited by size' then you are telling it to use the
size of the variable, ie 30 characters or whatever arrayvar is. You
need to use a delimiting character or perhaps " " (two spaces. You
also need to look at the 'with pointer' clause which specifies where
the string is to start.

You need to space fill the output first. Set the pointer to 1.
I upper cased the added parts. Note I removed txtvar from the string
input list. Txtpoint will be updated by each string to give
concatenation.

MOVE SPACES TO TXTVAR
MOVE 1 TO TXTPOINT
perform varying ws-counter from 1 by 1 until ws-counter = 10
IF ( WS-COUNTER > 1 )
STRING "," DELIMITED BY SIZE
INTO TXTVAR WITH POINTER TXTPOINT
END-IF
string arrayvar(ws-counter) delimited by " "
into txtvar WITH POINTER TXTPOINT
end-perform

Thank you both. Especially for the addnl logic to avoid the leading
comma.

.



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 ... need to use a delimiting character or perhaps " " (two spaces. ... INTO TXTVAR WITH POINTER TXTPOINT ...
    (comp.lang.cobol)
  • Re: MVP Needed - Parse a string of text from a linked .txt file
    ... delimiting the string on the comma. ... Dim rs As DAO.Recordset ... Dim strAddrPartsAs String ...
    (microsoft.public.access.modulesdaovba)
  • Re: Resrict method + include reccurrences
    ... I AM delimiting the string value in my code. ... > single or double quotes. ... > Reminder Manager, Extended Reminders, Attachment Options ...
    (microsoft.public.office.developer.outlook.forms)
  • Re: C Interoperability - Strings
    ... were sticking with this method of delimiting) required a leading character in addition to a trailing character. ... The leading and trailing character must match and must be a character not present in the literal string itself. ... You could also add a function to set the string delimiter I guess, but it might be messy to make that globally available. ...
    (comp.lang.fortran)
  • Re: WHERE IntegerPrimaryfield IN List
    ... Yes I corrected myself in a reply to someone else, there _are_ parenthesis ... 'WHERE PersonID IN '; ... problem for me was in passing the string in as a parameter - if I pass it ... You ARE delimiting the elements in the string. ...
    (borland.public.delphi.database.ado)