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

  • The All New JSL Cookbook II - Soliciting Input

    We are in the process of revamping the JSL Cookbook to give it broader appeal, make it better organized, and easier to use. The focus will be on short projects (recipes) to help you improve your JSL. The recipes will include step-by-step instructions, completed code and a demonstration video. The first recipes will focus will be on less than obvious aspects of common tasks. Later we will develop ...

    DonMcCormack DonMcCormack
    JSL Cookbook - Archived |
    Feb 16, 2022 6:56 AM
    3988 views | 10 replies
  • Set and get credentials in the Credential Manager via PowerShell on Windows

    Access usernames and passwords without saving them in your script or code.

    ih ih
    JSL Cookbook - Archived |
    Oct 5, 2021 9:46 AM
    22444 views | 1 replies
  • Detecting macOS Dark Mode and Windows High Contrast Mode

    Problem When creating user interfaces in JMP, you may want to add some background or foreground colors to your displays. However, with JMP 15's new support for macOS Dark Mode and Windows High Contrast Mode, you need a way to detect if the user is in a dark or light appearance mode in order to have legible content. For example, you wouldn't want to set a light color as a background color or a dar...

    Justin_Chilton Justin_Chilton
    JSL Cookbook - Archived |
    Jun 23, 2021 11:30 AM
    2187 views | 0 replies
  • A routing function

    Get routing information from MapQuest without the need to care about details of the interface.

    bernd_heinen bernd_heinen
    JSL Cookbook - Archived |
    Sep 30, 2020 10:17 AM
    1159 views | 0 replies
  • The Crude MapQuest Call

    Get the code to submit a call to MapQuest REST APIs

    bernd_heinen bernd_heinen
    JSL Cookbook - Archived |
    Sep 8, 2020 1:08 AM
    1081 views | 0 replies
  • The stack mole

    Problem APIs and other machine generated code often delivers very complicated data structures. I found it helpful to have a tool that analyzes these structures and make them more accessible. Ideally, it would show the result as a graph. Solution So, I made this little script that crawls through stacked data collections reveals their hierarchy and shows it as a diagram. See my blog post for a mo...

    bernd_heinen bernd_heinen
    JSL Cookbook - Archived |
    Sep 8, 2020 12:45 AM
    1737 views | 0 replies
  • A Geo-coding function

    Get geo-codes from MapQuest without the need to care about details of the interface.

    bernd_heinen bernd_heinen
    JSL Cookbook - Archived |
    Sep 7, 2020 11:50 PM
    1124 views | 0 replies
  • Vertical Normal Distribution Polygon Shape (Graphics Scripting)

    ProblemI wanted to create this figure for a publication SolutionTo create the vertically oriented shaded/filled and truncated normal curves, I utilized the Polygon() graphics function.  The challenge was to easily and repeated be able to create that polygon that was scaled and located appropriately on a graph.    I did this using this function func_VNormalShape = Function( // create a polygon that...

    MathStatChem MathStatChem
    JSL Cookbook - Archived |
    Jun 3, 2020 3:28 AM
    1679 views | 0 replies
  • C++ Programmer's Guide to JSL

    Problem You know some C++ and have some idea what a C++ object is and need the 20 minute intro to JMP's scripting language.   Solution There is a JMP scripting index on the Help menu. It describes, together or separately, Functions, DisplayBoxes, and Objects. As you dig deeper, use the search it provides.JSL does not have typed variables; there is not a way to declare a double, float, int, or bo...

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Feb 21, 2020 5:14 AM
    5679 views | 2 replies
  • Open a file in the operating system default program

    Problem If you need to open a file in an external program, typically the JSL Open() function will work for you. However, if you want to open a file type that JMP knows how to import, you will probably end up with the file imported instead of opened in the external program. Opening an Excel file is a common use case for this. Solution To do this, we can use the JSL RunProgram() function. Windows...

    Justin_Chilton Justin_Chilton
    JSL Cookbook - Archived |
    Feb 5, 2020 10:17 AM
    2213 views | 0 replies
  • Sorting Lists

    ProblemYou have data in one or more lists or matrix vectors that you need to sort.SolutionUse Sort List() or Sort List Into(), Rank(), or put the lists and vectors in a data table and sort it. // Sort List example (makes new list) names = {"fred", "Andy", "Rory", "bess", "susy", "perl"}; sname = Sort List( names ); Show( names, sname );names = {"fred", "Andy", "Rory", "bess", "susy", "perl"}; // u...

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Jan 17, 2020 9:06 AM
    4834 views | 0 replies
  • Looping through an Associative Array's elements

    ProblemYou need to look at every element in an Associative ArraySolutionuse the <<First and <<Next messages
    // load a table of elements dt = Open( "https://en.wikipedia.org/wiki/List_of_chemical_elements", HTML Table( 4, Column Names( 2 ), Data Starts( 5 ) ) ); // make an associative array using "H" to lookup "Hydrogen" and some of its properties map_Symbol_To_Data = Associative Array( dt[1 :: 118,...

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Dec 4, 2019 10:51 AM
    6296 views | 5 replies
  • Insert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute

    Insert variables or expressions into other expressions.  This is a brief introduction to Eval(), Eval Expr(), Substitute(), Parse(), and Eval Insert().

    ih ih
    JSL Cookbook - Archived |
    Sep 9, 2019 2:18 PM
    19347 views | 10 replies
  • Using Loc with a 2D Matrix

    Problem You have a 2D matrix. You used the Loc function to locate interesting elements, but Loc returned indexes for a 1D matrix. How can you convert the 1D indexes back to 2D indexes? Solution You'll need to use the Floor and Mod functions and you'll need to know the number of columns in your 2D matrix. Here's the three lines, buried in the commented example below. pixmat is a 2D matrix, Loc i...

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Apr 26, 2019 4:29 PM
    4233 views | 1 replies
  • Concatenate data tables

    Problem Concatenate data tables using Files in Directory, without using Multiple File Import   Solution Use Files in Directory to make a list and Concatenate to put them together.   // make a test directory dt = New Table( "Untitled", Add Rows( 1 ), New Column( "a" ), New Column( "b" ) ); path = "$TEMP/test/"; Delete Directory( path ); // Be careful! This will delete your files! Create Director...

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Nov 3, 2018 5:14 AM
    7554 views | 4 replies
  • 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:35 AM
    4552 views | 0 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 11, 2018 4:45 AM
    2997 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 10, 2018 11:48 AM
    4336 views | 1 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
    3778 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 |
    Apr 20, 2018 8:29 AM
    5986 views | 3 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 |
    Apr 3, 2018 12:52 PM
    7750 views | 1 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 |
    Feb 14, 2018 1:14 PM
    14815 views | 6 replies
  • Get a list of the unique values in a column, matrix, or list

    ProblemProblem 1:  I need to get a list of the unique values in a data table column.Problem 2:  I need to get a list of the unique values in a JSL data structure (list or matrix)SolutionFor problem 1:Solution 1:  Use summary tables.  The JSL below shows how to use Summary() to get a table that will have a row with each unique value in a single column.   You can then do further JSL table commands t...

    MathStatChem MathStatChem
    JSL Cookbook - Archived |
    Feb 14, 2018 5:59 AM
    12470 views | 1 replies
  • Loops

    Problem You need to execute some JSL more than once. Solution Use a for(...) or while(...) or one of the more exotic variations.
    The for loop is the most common way to repeat some statements. Cars = {"Ford", "Chevy", "Tesla"}; // a list
    nCars = N Items( Cars );
    // notice loop starts at one and <= counts to the end
    For( iCar = 1, iCar <= nCars, iCar += 1,
    car = Cars[iCar]; // JSL lists are 1-based
    ...

    Craige_Hales Craige_Hales
    JSL Cookbook - Archived |
    Feb 11, 2018 8:52 AM
    28773 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
    3632 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.