Introduction to JMP 10 Application Builder JSL Roundtable

Introduction to JMP 10 Application Builder JSL Roundtable JMP Discovery 2013, San Antonio September 12, 2013 Peter Mroz Statistical Programmer Methods & Analyses Global Medical Safety Janssen Research & Development

Agenda • Introduction • Why Use Application Builder? • Terminology • Instant Application • Custom Application • Useful Resources • Conclusions Janssen Research & Development

Introduction What is Application Builder? • User interface builder, report generator • Drag-and-drop interface, analogous to Visual Studio • Visually design windows with buttons, lists, graphs, etc. • Write scripts to control the functionality of each object • Boost the productivity of experienced (JSL) programmers Janssen Research & Development 2

Why use Application Builder? • Visual layout environment • Easier to design dialog boxes than with the old manual process • Application development without JSL • Modular application design • Integrated debugging • Multiple deployment paths – Script, data Table, Add-In, file • Ease of maintenance Janssen Research & Development 3

Additional Advantages • Excellent for prototyping • Revisions are easier than doing it “the old way” Janssen Research & Development 4

Terminology • JMP Application: top-level file that consists of one or more modules • Module: a collection of objects, messages, instances, and other JSL statements that are compiled into an application • Module Instance: the occurrence of a module in the application. In a complex application, you might have a startup script that creates multiple instances of one or more modules. • Instant Application: an application that typically consists of reports and does not require JSL scripting • Custom Application: an application that demonstrates custom behavior through JSL scripting Janssen Research & Development 5

Instant Application • Quickly create applications without writing JSL • Arrange reports, graphs, and other objects to make them easy to interact with at once. • Example: Open Big Class, run several of the programs listed in the table panel: • CTRL-SHIFT-A brings up Application Builder, showing reports in the Reports Section • Drag desired reports to the application workspace • Click the Run button to display the report Janssen Research & Development 6

Instant Application Example Janssen Research & Development 7

Instant Application Example (design mode) Janssen Research & Development 8

Instant Application Example (running) Janssen Research & Development 9

Sample Applications Installed with JMP Program File Description Capability Six Pack. jmpappsource Creates two XBar Control Charts and a Distribution report. Data Filter Compare. jmpappsource Creates two Bubble Plots, each with its own data filter and Tabulate report. See this application for an example of the Data Filter Context Box function. Data Table Application. jmpappsource Lets the user select data table columns to stratify and the sampling rate. Display the data table to see the results. Instant App. jmpappsource Combines two Multivariate reports (Principal Components/Factor Analysis and T Square with All Principal Components). Launcher With Report. jmpappsource Lets the user select data table columns in a launch window and then creates a graph. Parameterized Instant App. jmpappsource Lets the user select data table columns and then creates two Multivariate reports. A parameter is assigned to the Y role. This means that the reports can be created from any open data table, not just the table specified in the application Parameterized Measurement Systems Analysis (MSA) Combo Chart. jmpappsource Creates a collection of reports for Measurement System Analysis (MSA). Presentation. jmpappsource Creates an onscreen presentation, similar to a slideshow, with navigation buttons and an embedded script R Application. jmpappsource Lets the user select columns and then shows multivariate data in the shape of a face (the Chernoff faces). Requires the R Teaching. Demos package. SAS Application. jmpappsource: Runs a SAS script and then adds the output to a report. Prompts you to log on to a SAS server if you are not already connected Janssen Research & Development 10

Custom Application: Table-Chart • Functionality – Select table from list of existing open tables – Select X, Y, Grouping columns – Select type of chart(s) to create – Create chart • Design screen • Develop “paper prototype” for user review • Attach JSL logic to objects Janssen Research & Development 11

Initial screen layout Table Info Select table: # Rows: # Cols: Columns X Column Y Column(s) Grouping Variable Remove Charts to make Actions x x Create Chart X-Y Chart Bar Chart Exit Janssen Research & Development 12

Containers for screen Vlist Box Panel Box Lineup Box Hlist Box Panel Box Hlist Box Janssen Research & Development 13

Containers for screen Vlist Box Table Info Panel Box Lineup Box Select table: # Rows: # Cols: Panel Box Lineup Box Hlist Box Columns X Column Y Column(s) Grouping Variable Remove Panel Box Charts to make x x X-Y Chart Bar Chart Panel Box Actions Create Chart Hlist Box Exit Janssen Research & Development 14

Layout in Application Builder Janssen Research & Development 15

Add objects and name appropriately Janssen Research & Development 16

Click Run button for first look • Needs some tweaking • Resize table combo box • Resize list boxes – Columns – X column – Y Columns – Grouping Variable • Both charts selected by default Janssen Research & Development 17

Click the Scripts tab Janssen Research & Development 18

Add JSL code // // // This script is executed when a new module instance is created. The pre-defined object "this. Module. Instance" refers to the instance object, but other objects such as boxes and scripts have not yet been created. Variables declared here are scoped to the Module. Instance namespace. // This special function will receive parameters passed to Create. Instance() On. Module. Load({}, ); this. Module. Instance << Create Objects; // After this point your module instance objects have been created // and can be referred to by name (for example, "Button 1"). columns_listbox xcol_listbox ycol_listbox group_var_listbox << << Set Set Size( 200, 150 ); 30 ); 60 ); 30 ); charts_checkbox << set(1, 1) << set(2, 1); Janssen Research & Development 19

Looks much better… Janssen Research & Development 20

Next steps • Preload the table combobox with a list of open tables • Add JSL logic to table combobox if a different table is selected • Load the column information listbox with a list of columns for the currently selected table • Add JSL logic for buttons Janssen Research & Development 21

Preload the table combobox // Preload the table combobox with a list of existing tables default_table = current data table() << get name; table_list = {}; ntables = ntable(); For (i = 1, i <= ntables, i++, one_name = Data Table(i) << Get Name; table_list[i] = one_name; // For the default table load up the columns list box if (one_name == default_table, idefault = i; col_list = data table(i) << get column names (as string) ; columns_listbox << set items(col_list); nrows_text << set text(char(nrow(data table(i)))); ncols_text << set text(char(ncol(data table(i)))); ); ); // Add the list of tables to the combo box select_table_combo << set items(table_list); // Make the current table preselected select_table_combo << set(idefault); Janssen Research & Development 22

Add JSL logic for table combobox function • Right click on table combobox, then Scripts > Select • Creates named function in Scripts tab • The this parameter tells which control is calling the function. select_table_Combo. Select =Function({this}, {selected. Index}, // This function is called when the Combo Box selection changes selected. Index = this << Get Selected; ); Janssen Research & Development 23

Add JSL logic for table combobox function //---------------------------------------select_table_Combo. Select =Function({this}, {selected. Index}, // This function is called when the Combo Box selection changes selected. Index = this << Get Selected; col_list = data table(selected. Index) << get column names (as string) ; columns_listbox << remove all; columns_listbox << set items(col_list); nrows_text << set text(char(nrow(data table(selected. Index)))); ncols_text << set text(char(ncol(data table(selected. Index)))); // Clear out the various xcol_listbox << ycol_listbox << group_var_listbox << list boxes remove all; ); // end select_table_Combo. Select Janssen Research & Development 24

How does the screen look now? Janssen Research & Development 25

Add JSL logic for buttons • Create functions for each button • Right click on each button and select Script > Press • Functions are added to the Scripts tab xcol_button. Press=Function({this}, // This function is called when the button is pressed name = this << Get Button Name; ); Janssen Research & Development 26

X Column button function //---------------------------------------xcol_button. Press=Function({this}, one_list = columns_listbox << get selected; nlist = nitems(one_list); if (nlist > 0, // Clear out anything in this listbox xcol_listbox << remove all; // Only take the first item selected if (nlist > 1, remove from(one_list, 2, (nlist - 1)); ); // Add the selected column to the list xcol_listbox << append(one_list); ); // end if ); // end xcol_button. Press Janssen Research & Development 27

Y Column(s) button function //---------------------------------------ycolumn_button. Press=Function({this}, // Add all selected columns to this listbox ycol_listbox << append(columns_listbox << get selected); ); // end ycolumn_button. Press Janssen Research & Development 28

Remove button function //---------------------------------------remove_button. Press=Function({this}, // Remove anything highlighted in the xcol, ycol and group variable listboxes xcol_listbox << removeselected; ycol_listbox << removeselected; group_var_listbox << removeselected; ); // end remove_button. Press Janssen Research & Development 29

Create Charts button function • Use all inputs to create one or two charts • If not enough information has been provided display an error message • Dynamically build JSL code to create X-Y or Bar Chart • Call eval(parse() to create the charts Janssen Research & Development 30

Create Charts button function (1) create_chart_button. Press =Function({this}, keep_going = 1; // Check to see if enough information was provided xcolumn_list = xcol_listbox << get items; if (nitems(xcolumn_list) == 0, keep_going = 0; nw = new window("No X Column", << modal, textbox("No column has been selected for X" ) ); ); if (keep_going, xcolumn = xcolumn_list[1]; ycolumn_list = ycol_listbox << get items; if (nitems(ycolumn_list) == 0, keep_going = 0; nw = new window("No Y Columns", << modal, textbox("No columns have been selected for Y" ) ); ); ); if (keep_going, chart_list = charts_checkbox << Get Selected(); if (nitems(chart_list) == 0, keep_going = 0; nw = new window("No Charts Selected", << modal, textbox("No charts have been selected" ) ); ); ); Janssen Research & Development 31

Create Charts button function (2) if (keep_going, // If we get here we have enough information to create some charts table_name = select_table_Combo << Get Selected; dt = data table(table_name); current data table (dt); // See if there's a grouping variable group_var_list = group_var_listbox << get items; if (nitems(group_var_list) == 0, // then overlay_string = "", // else group_variable = group_var_list[1]; overlay_string = evalinsert("[, Overlay( : name("^group_variable^") )]" ); ); elements_string = ""; for (i = 1, i <= nitems(ycolumn_list), i++, ycolumn = ycolumn_list[i]; if (i == 1, y_string = evalinsert("[ , Y( : name("^ycolumn^") ) ]" ); , y_string = y_string || evalinsert( "[ , Y( : name("^ycolumn^"), Position(1) ) ]" ); ); // Build the elements string elements_string = elements_string || ", Y(" || char(i) || ") "; ); // end i for loop Janssen Research & Development 32

Create Charts button function (3) // Dynamically create a script for the desired chart(s) and execute it for (i = 1, i <= nitems(chart_list), i++, if (chart_list[i] == "X-Y Chart", chart_expr = evalinsert("[ Graph Builder( Show Control Panel( 0 ), Variables( X( : name("^xcolumn^") ) ^y_string^ ^overlay_string^ ), Elements( Points( X ^elements_string^, Legend( 1 ) ) ), Send. To. Report( Dispatch( {}, "Graph Builder", Frame. Box, {Marker Size( 2 )} ) ) )]"); // Draw the X-Y chart eval(parse(chart_expr)); ); // end if X-Y chart Janssen Research & Development 33
![Create Charts button function (4) if (chart_list[i] == "Bar Chart", chart_expr = evalinsert("[ Graph Create Charts button function (4) if (chart_list[i] == "Bar Chart", chart_expr = evalinsert("[ Graph](http://slidetodoc.com/presentation_image_h/334611b635ccb5e67ef573cc92c7e8c7/image-35.jpg)
Create Charts button function (4) if (chart_list[i] == "Bar Chart", chart_expr = evalinsert("[ Graph Builder( Show Control Panel( 0 ), Variables( X( : name("^xcolumn^") ) ^y_string^ ^overlay_string^ ), Elements( Bar( X ^elements_string^, Legend( 4 ), Bar Style( "Side by side" ), Summary Statistic( "Mean" ) )]"); // Draw the Bar chart eval(parse(chart_expr)); ); // end if Bar chart ); // end i for loop ); // end if keep going ); // end create_chart_button. Press Janssen Research & Development 34

Last function: the Exit button //---------------------------------------exit_button. Press=Function({this}, this << close window; ); // end exit_button. Press Janssen Research & Development 35

Useful Resources • Scripting Index – Help > Scripting Index – Lots of code samples • JMP File Exchange Janssen Research & Development 36

Scripting Index Janssen Research & Development 37

Great addin for JMP icons • Called “Icon Names v 2” • Written by Jeremy Francis, Intel • Shows all icons available in JMP, along with their name • Icons add a professional touch to your interface • Available in the JMP File Exchange • http: //support. sas. com/demosdownloads/downarea_t 4. jsp? p roduct. ID=114021&jmpflag=N Janssen Research & Development 38

Icon Names Addin • Find the desired icon • Enter the name into the Icon property for a button Janssen Research & Development 39

Conclusions • Pros – Prototyping – Revisions – Layout easier – Most objects available • Cons – Version 1. 0 in JMP 10. 0 – Learning curve – No modal dialog boxes – Need more examples Janssen Research & Development 40

Code Techniques • Substitute variables into string with evalinsert and ^ a = "Hello"; b = "world"; c = evalinsert("This is a long string. Hello world. " ^a^ ^b^. "); • Ignore quotes within strings using “[…]” d = "[This string has "embedded" double quotes]"; "This string has !"embedded!" double quotes" Janssen Research & Development 41

Code Techniques • Execute string with eval(parse()) cmds = "[dt = open("$sample_dataBig Class. jmp"); gb = Graph Builder(Show Control Panel( 0 Variables( X( : weight ), Y( : height Elements( Points( X, Y, Legend( 1 ) Smoother( X, Y, Legend( 3 eval(parse(cmds)); ), ), ) ); ]"; Janssen Research & Development 42
- Slides: 43