cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Neo
Neo
Level VI

How to concatenate rows in a given column to a string in JSL?

If I have a datatable dt with one column col1 and several rows containing characters e.g. a, b, c, d i.e. one character per row. How do I get a string of the form myString = 'a','b', 'c', 'd' ?

 

If I do this

 

 

x = Associative Array( dt:"col1" ) << Get Keys; show (x);

it gives me

 

 

x = {"a", "b", "c", "d"};

whereas I would like to get a string 

myString = 'a', 'b', 'c', 'd'

to use further in my next line of code.

 

Any directions would be helpful.

 

Thanks.

When it's too good to be true, it's neither
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How to concatenate rows in a given column to a string in JSL?

Use Concat Items after you have the list

Names Default To Here(1);

x = {"a", "b", "c", "d"};

my_string = "'" || Concat Items(x, "','") ||"'";

Write(my_string); // 'a','b','c','d'

 

 

 

 

-Jarmo

View solution in original post

1 REPLY 1
jthi
Super User

Re: How to concatenate rows in a given column to a string in JSL?

Use Concat Items after you have the list

Names Default To Here(1);

x = {"a", "b", "c", "d"};

my_string = "'" || Concat Items(x, "','") ||"'";

Write(my_string); // 'a','b','c','d'

 

 

 

 

-Jarmo