cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
Choose Language Hide Translation Bar
vishwasanj
Level V

Repeat a sequence in a column -JSL

I was looking into the scripting guide, and it talks about Sequence( from, to, stepsize, repeat ); with from, to , stepsize and repeat.

 

What if I want 3 values say, 1, 50000, 100000 repeated till the end of table in a column? (This is basically highlighting the 3 values in a column and right click and say fill to the end of the table)

Do i have to run a for loop, or is there like a one line script available in JSL? 

 

Thank you so much for your suggestions. 

1 ACCEPTED SOLUTION

Accepted Solutions
David_Burnham
Super User (Alumni)

Re: Repeat a sequence in a column -JSL

Here is some code to play with

lst = {1,50000,100000};
nRepeats = 10;
values = Repeat(lst,nRepeats); // this will be a list of 30 values
values[1::NRows(dt);
Column(dt,"Test") << Set Values(values);
// if the table only had 25 rows I could use values[1::25]
-Dave

View solution in original post

3 REPLIES 3

Re: Repeat a sequence in a column -JSL

Notice that when you select Cols > New Column, there is an option near the bottom of the dialog to initialize the new column in several ways including a sequence. If you created the new column by double-clicking to the right of the last column, then select the new, empty column and select Cols > Column Info to see the same feature.

Note that this feature disappears as soon as you enter any values in the column another way.

No formula or script necessary for a simple case like this one. Already provdided for,

PS_Ato
Level III

Re: Repeat a sequence in a column -JSL

Hi Mark,

this was new for me - thank you. Could you please help me how to create a script? We import data regularily and always need to add columns with e.g. 10 repetitions each value (from 1 to 16).

David_Burnham
Super User (Alumni)

Re: Repeat a sequence in a column -JSL

Here is some code to play with

lst = {1,50000,100000};
nRepeats = 10;
values = Repeat(lst,nRepeats); // this will be a list of 30 values
values[1::NRows(dt);
Column(dt,"Test") << Set Values(values);
// if the table only had 25 rows I could use values[1::25]
-Dave