cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.

JSL Cookbook - Archived

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

Latest Posts

  • Search a string for all occurrences of a pattern

    Problem Find the positions of all occurrences of a pattern within a string. (Thanks @DonMcCormack ) Solution Use the pattern matching functions source = "this is a racecar and ere noon stressed desserts for Stanley Yelnats saw Anna was there"; palindrome = (Pat Regex( "[a-zA-Z][a-zA-Z ]{0,999}" )) >> firstpart + // one or more first letters (Pat Regex( "[a-zA-Z ]{0,1}" )) + // optional middle ...

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Oct 20, 2018 8:28 AM
    4205 views | 0 replies
  • Add favorite formula columns to a table

    ProblemYou want to add the same set of new, formula-based columns to your data over and over again.SolutionStore the formulas and column names in a table.  Extract them from that table. loop over them trying to make a new column for each pair in your target data table.
    favorite_formulas=function({dt1=currentdatatable(),FFpath},{default local}, /* adds formulas to a data table from another data t...

    hardner hardner
    JSL Cookbook - Archived |
    Jul 11, 2018 4:52 AM
    4173 views | 1 replies
  • Add a data-driven graph thumbnail to a graph tooltip

    Problem While looking at an aggregated data visualization, I want to get insights into the underlying data distribution by having the associated histogram displayed directly on the graph tooltip.  Solution 1) Create an "expression" type column (so that its value is treated as an image); 2) Add a "formula" property to it using the JSL listed below. 3) Set the "Label" flag for this column (so tha...

    nascif_jmp nascif_jmp
    JSL Cookbook - Archived |
    Jul 10, 2018 11:49 AM
    2874 views | 0 replies
  • Combined and Connected Number Edit Box and Slider Box

    ProblemIn many situations, when you are using a slider box to control a numeric variable, you also want a editable number display to display the value of the variable, and that allows you to manually set the value of the variable.   The current way to do this is to create two display objects: a Number Edit Box() and a Slider Box().  You have to code this in such a way that they are connected.  In ...

    MathStatChem MathStatChem
    JSL Cookbook - Archived |
    May 25, 2018 12:24 PM
    5611 views | 3 replies
  • Geographic Maps with Graphs as Markers

      Problem   Create a geographic map with "graphlets" positioned over associated map locations. Solution Context is everything! So just as one might want to embed tiny line charts in a text block as sparklines to show them in the context of a discussion, someone might want to embed tiny bar charts in a map to compare variables in the context of their location. Someone like our own @scwise, who...

    nascif_jmp nascif_jmp
    JSL Cookbook - Archived |
    Apr 20, 2018 8:31 AM
    3580 views | 0 replies
  • Reading JSON data with a REST API

    Problem Some web sites provide a REST API to read data, and often the response is text in JSON format. How do we get that into JMP? Solution Here is a example using the meetup.com REST API. It's relatively simple since it uses the common "GET" method, which is the default for web page reading. More elaborate messages use the "POST" method which would require a different approach. With the GET r...

    XanGregg XanGregg
    JSL Cookbook - Archived |
    Apr 12, 2018 1:29 PM
    13935 views | 6 replies
  • Extract Statistics from an Analysis into a Report

    Problem You run an analysis in JMP and want to extract some of the statistics from the platform report. Then you want to place those statistics into a custom report window, so that you can keep those after the data table and platform report are closed. Solution You can get a reference to the report layer of the analysis report and use JSL messages to extract statistics out of  In this example, ...

    michael_jmp michael_jmp
    JSL Cookbook - Archived |
    Mar 26, 2018 6:54 AM
    7368 views | 1 replies
  • 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 |
    Feb 13, 2018 4:32 PM
    7948 views | 2 replies
  • Extracting colors from a #rrggbb column

    Problem You have colors in the HTML format "#RRGGBB" and you want to use them in JMP graphs. For instance, here is the data set I used for the world metro stations scatter plot. The color column is a character column with six hexadecimal digits, two for each of the color components.
      Solution 1: Row Colors In a JMP table, each row can have a few attributes associated with it, including color a...

    XanGregg XanGregg
    JSL Cookbook - Archived |
    Jan 30, 2018 1:03 PM
    3454 views | 0 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
    3969 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:18 AM
    3211 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:47 AM
    2411 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
    2807 views | 0 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
    3145 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
    2761 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
    2655 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 1:25 PM
    2558 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:06 PM
    2054 views | 0 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:17 PM
    4212 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 1:24 PM
    1604 views | 0 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 |
    Jul 24, 2017 12:53 PM
    16425 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 |
    Jul 10, 2017 12:14 PM
    1545 views | 0 replies
  • Saving Custom Animations

    Animated GIF of spline tension adjustment

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Jul 9, 2017 1:47 PM
    3056 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:38 AM
    1014 views | 0 replies
  • Create a Box Plot from a Five-Number Summary

    Problem Instead of a full data set, you have a summarized version that contains the five numbers needed to define a box plot. Solution You can use frequencies to mimic a full data set based on the five-number summary. If you enter the five data points in a data table and then create a second column with frequencies that force your data points to be at the appropriate quantiles, you can use that...

    michael_jmp michael_jmp
    JSL Cookbook - Archived |
    Jun 27, 2017 12:48 PM
    1569 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.