Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

- JMP User Community
- :
- Discussions
- :
- JSL Script Continue Sequence to End of Table

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Created:
Oct 19, 2018 2:39 AM
| Last Modified: Oct 19, 2018 8:30 AM
(4409 views)

Hi,

I am new to JSL script. Can anyone teach me how to write the script for below option, "Continue sequence to end of table". I would like to automate this process. I only able to find script to key in the first three rows as below:

```
dt << New Column("Time","Continuous", Set Values([1,2,3]));
```

Then not sure how to automate it if I want to Continue sequence to end of table.

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

There are some functions available interactively that don't have JSL equivalents. Most of these are things that only make sense interactively. In this case, it's assumed that as a JSL author you can create the data you want as you want it.

For the pattern you're looking for you should examine the Row(), Count(), and Sequence() functions.

```
New Table( "Sequences",
Add Rows( 20 ),
New Column( "Row",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Row() )
),
New Column( "Count",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Count( 10, 30, 21, 1 ) )
),
New Column( "Sequence",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Sequence( 100, 130, 0.5, 2 ) )
)
);
```

-Jeff

2 REPLIES 2

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: JSL Script Continue Sequence to End of Table

If you just want to fill the column with the sequence 1, 2, ..., you can use this JSL:

```
dt=Current Data Table();
dt << New Column("ABCD", Numeric, Continuous, Set Values(1::NRows(dt)));
```

The statement

`a::b`

,where a and b are integers, creates a vector of sequencial values from a to b, indexed by 1. More generally, a::b::increment returns [a a+increment a+2*increment ... b]. For example

`2::20::2`

returns [2 4 6 8 10 12 14 16 18 20]

If you want a script that will contine the sequence based on the selected rows, that would be a little bit more work to create, I think.

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

There are some functions available interactively that don't have JSL equivalents. Most of these are things that only make sense interactively. In this case, it's assumed that as a JSL author you can create the data you want as you want it.

For the pattern you're looking for you should examine the Row(), Count(), and Sequence() functions.

```
New Table( "Sequences",
Add Rows( 20 ),
New Column( "Row",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Row() )
),
New Column( "Count",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Count( 10, 30, 21, 1 ) )
),
New Column( "Sequence",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Sequence( 100, 130, 0.5, 2 ) )
)
);
```

-Jeff

Article Labels

There are no labels assigned to this post.