cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.

JSL Cookbook - Archived

Building blocks of JSL code to reduce your coding workload.
Choose Language Hide Translation Bar

Latest Posts

  • Sort a Data Table

    Problem You need to sort a table using one or more columns as the sort key. Solution Use the table's sort method, which supports ascending and descending order and in-place or new table sorting. // run these lines, one at a time, to see the effects // (place the cursor on the line and use the Enter key // on the numeric keypad to easily submit the line.) dt = Open( "$sample_data/big class.jmp...

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Jan 30, 2018 11:06 AM
    8317 views | 2 replies
  • Custom Button Icons

    Problem You need special purpose icons on buttons. Solution Make your own pictures and specify them as the icon for a button. First, an easy example, where you might use ms-paint to make a bitmap New Window( "hello", Button Box( "optional text", <<setIcon( "$desktop/hi.jpg" ) ) )   Huge button icon without transparency You might want to have an empty string for the optional text, and you'll pro...

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Jan 26, 2018 8:40 AM
    4181 views | 0 replies
  • Path Variables to deal with my disorganized files.

    Use  the Set Path Variable function to simplify file paths so that they work well Mac and PC operating systems

    Byron_JMP Byron_JMP
    JSL Cookbook - Archived |
    Jan 23, 2018 11:19 AM
    3332 views | 0 replies
  • Rotate a List

    Problem You have a list of items that you want to rotate, moving items from the beginning of the list to the end or the end to the beginning. You might think of the list as circular. Rotate a circular list Solution Use the Shift Into function, which does exactly that. list = {"ape", "bat", "cow", "doe", "ewe", "fox", "gnu", "hog"}; Shift Into( list, 1 ); // move one from the front to the end S...

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Jan 9, 2018 9:50 AM
    2492 views | 0 replies
  • New Year Countdown

    Problem You need a countdown timer for New Year's Eve, and for some reason, you need it built from unlikely display boxes. Solution Use a LineUp box to hold a bunch of spacer boxes to form 7-segment LED displays. Control the color of the spacer boxes to make the digits.7-segment display countdown clock seglength = 50; // long dimension of one of the 7 segments segwidth = 3; // narrow dimension ...

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Dec 27, 2017 6:15 PM
    2940 views | 0 replies
  • Write Your Own Functions

    Problem You have some code that you want to call from more than one place, maybe with different arguments. Solution Use a user written function, with parameters, local variables to keep them away from other code, and a return statement to send back an answer. // this example shows how to write a user written function to roll // ndice with nsides // a user written function is created with an a...

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Dec 26, 2017 7:33 AM
    15918 views | 3 replies
  • Write reusable JSL

    Problem You have JSL that can be used in more than one project, with minor changes, and you want to keep one copy to make it easier to maintain. Solution Use a separate file and include it into a main program. Use namespaces to keep variables isolated from other modules. Build the namespaces so the main program can add customizations. // "example.jsl" reusable, extensible module example = Ne...

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Dec 25, 2017 1:36 PM
    3218 views | 0 replies
  • Close Data Table when Report Closes

    Problem You've opened a table to show a report. The table might be temporary or invisible, and you want the table to go away silently when the report is closed. Solution Use the <<OnClose method to attach a script to the report. Make the script close the table. // make a table dt = New Table( "Temporary", Add Rows( 1e6 ), New Column( "x", Formula( Random Normal( 50, 30 ) ) ), New Co...

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Dec 24, 2017 7:09 AM
    2870 views | 0 replies
  • Insert different reports into one JMP report window

      Problem   As a JMP HTML5 tester, what I often do is to generate a JMP report, and then export it to HTML5. However, I want to cover more testing cases for each exporting. For example, for step line chart testing, I want to see if HTML5 behaves correct for line connection types of Step, Centered Step, and other features.       Solution I use new window to hold all reports. Simply insert JSL exp...

    Hui_Di Hui_Di
    JSL Cookbook - Archived |
    Dec 19, 2017 2:16 PM
    2660 views | 0 replies
  • Parsing an RSS Feed (or any XML structure) into a JMP Data Table

    Problem You have some XML data that you want to import into a JMP Data Table. In this example, I am using the JMP User Community's RSS feed for add-ins found here. Below is a snippet of the feed. <rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modu...

    Justin_Chilton Justin_Chilton
    JSL Cookbook - Archived |
    Dec 19, 2017 2:01 PM
    2835 views | 0 replies
  • Compress a Folder into a Zip File

      Problem   You need to compress an entire folder into a single ".zip" file.   Solution   Use JMP's built-in support for compressing files to create a ZipArchive object. Once you have a ZipArchive object, you can write blob representations of the uncompressed files to the ".zip" file.   /* Arguments: folderToZip - "path" - path to the folder you want to compress zipFileLoc - "path" - path ...

    Justin_Chilton Justin_Chilton
    JSL Cookbook - Archived |
    Dec 19, 2017 1:08 PM
    2242 views | 0 replies
  • Using Slider Boxes

    Problem You want to use a Slider Box to set a continuous value, and you want to see the current value as you move the slider. Solution Make a Slider Box and a Number Edit Box. Add a script to the Slider Box to update the Number Edit Box. Add a script to the Number Edit Box to update the Slider Box. Eggs = 50; Bacon = 50; New Window( "Slider Display", Border Box( Left( 10 ), Right( 10 ), top...

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Dec 19, 2017 12:26 PM
    7525 views | 4 replies
  • Custom Table Calculator

    Problem You need to build a custom calculator that displays a table of numbers based on several input values. Solution Use Number Edit Boxes to get the values and use the Set Function method to attach JSL to the Number Edit Boxes to recalculate the table when the values are changed. Use a Table Box to hold columns of numbers. Rebuild the columns of numbers when the values change. Payment table ...

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Dec 15, 2017 12:09 PM
    3210 views | 3 replies
  • Get a list of websites from a list of search terms: JMP and Python

    Problem I'm doing a bunch of research on a long list of companies and I want to know what their websites are. A good indicator that a company has be acquired is that either its website is missing or their compay website points to a company with a different name.  So I want to take a column of company names, submit them to a web search and get back the most likely website.   I'm ok with imperfect ...

    Byron_JMP Byron_JMP
    JSL Cookbook - Archived |
    Dec 14, 2017 3:12 PM
    4444 views | 2 replies
  • Build a data table from a string using pattern matching

    Problem You have a text string that has a repeating pattern. You want to extract some data from the string into a data table. Each repetition in the string represents a row in the table. There might be a lot of data to skip over because it doesn't belong in the table. Solution Use the JSL PatMatch function. You'll need to use the pat___ functions to build a pattern. The following example makes ...

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Dec 12, 2017 2:13 PM
    1684 views | 0 replies
  • Convert Matrix to Data Table and Back

    Problem You have data in a Matrix and need a Data Table, or the other way 'round Data table or matrix? Solution There is a function, AsTable(), that makes a new data table from a matrix, and a data table method, GetAsMatrix(), that makes a matrix from the numeric columns in a table. There is also a way to index data tables directly with data table subscripting.
    // make a matrix of 5 rows, 3 col...

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Dec 12, 2017 10:06 AM
    6970 views | 2 replies
  • JSL to Create a New Data Table

    Problem You are writing JSL to make a data table and you are not sure how to script creating the table and columns. Solution Make a data table, using JMP's GUI, that looks the way you want. Add the numeric formats (dates, etc) to the columns that need them, and formula columns too. Then delete the rows, or leave the rows with the default data you need. Finally, use the red triangle and pick "Co...

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Dec 11, 2017 8:14 AM
    16769 views | 0 replies
  • Select rows from the currently selected rows

    Problem Suppose your data table has a set of rows selected.  Now, you want to select rows from that selection that meet an additional condition. Solution The Select Where() message for the Data Table object offers an option that allows you to specify to select from the current selection. The following example demonstrates how to use the Current Selection() option to restrict the new selection t...

    Wendy_Murphrey Wendy_Murphrey
    JSL Cookbook - Archived |
    Nov 2, 2017 12:27 PM
    4649 views | 2 replies
  • Select rows based upon multiple conditions

    Problem Suppose you wish to select rows in a data table that meet more than one condition. Or, maybe you want to select the rows that meet one of a few conditions.   Solution The following examples demonstrate how you can use the logical AND (&) and OR (|) operators with the Select Where message to select rows that meet multiple conditions.  See the embedded comments for details.    /* Open a s...

    Wendy_Murphrey Wendy_Murphrey
    JSL Cookbook - Archived |
    Nov 2, 2017 12:25 PM
    6993 views | 2 replies
  • Select rows that match any value in a list

    Problem Suppose you prompt a user to make a selection. When you retrieve the values from the user, typically they are stored in a list.  Now you need to select the data that matches the values in the list. Solution The following example demonstrates how you can select rows in a data table that contain any value stored in a JSL list. Lists containing either numeric values or character strings ca...

    Wendy_Murphrey Wendy_Murphrey
    JSL Cookbook - Archived |
    Oct 30, 2017 1:34 PM
    9793 views | 5 replies
  • Use Summary to Automatically Add Reference Lines to Graph Builder

    reference lines automatically added using JSL

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Aug 8, 2017 7:28 AM
    5897 views | 1 replies
  • Saving Custom Animations

    Animated GIF of spline tension adjustment

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Aug 8, 2017 7:26 AM
    3179 views | 0 replies
  • Retrieve Values from a Modeless Dialog Box

    Problem Many applications require prompting the user for inputs or choices and then acting on that input. This recipe creates a modeless (i.e., non-modal) dialog box with choices. When the user clicks the Okay button to dismiss the window, it stores the user inputs into variables and then does whatever work is required.  Solution The New Window() function will create a window you can use to pro...

    Jeff_Perkinson Jeff_Perkinson
    JSL Cookbook - Archived |
    Aug 8, 2017 7:21 AM
    1609 views | 0 replies
  • Create a Formula Column

    Problem You want to create a new data table column that contains values that are based on the evaluation of a formula. The formula uses the value of another column to determine the value in the new column. Solution This solution uses the Big Class sample data table and creates a formula that uses the value of the Age column to determine a resulting category for a new column called Adolescent Ph...

    michael_jmp michael_jmp
    JSL Cookbook - Archived |
    Aug 8, 2017 6:52 AM
    3350 views | 0 replies
  • Screen outliers in sensor values outside the plausible range of measurement.

    Problem Often, sensors recording values of system have specification of operating range and/or minimum and maximum allowable values. For various reasons, sensor occasionally send spurious values, which are out of the range of what the sensor is physically capable of recording. We'd like to deal with these spurious values before analyzing or graphing our sensor data. Solution We will add a range...

    Daniel_Valente Daniel_Valente
    JSL Cookbook - Archived |
    Jul 8, 2017 6:44 AM
    1071 views | 0 replies
JSL Cookbook

If you’re looking for a code snippet or design pattern that performs a common task for your JSL project, the JSL Cookbook is for you.

This knowledge base contains building blocks of JSL code that you can use to reduce the amount of coding you have to do yourself.

It's also a great place to learn from the experts how to use JSL in new ways, with best practices.