cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
%3CLINGO-SUB%20id%3D%22lingo-sub-42309%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3EGuida%20per%20programmatori%20C%2B%2B%20a%20JSL%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-42309%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CDIV%20class%3D%22lia-message-template-problem-zone%22%3E%0A%3CH2%20id%3D%22toc-hId--1330512802%22%20id%3D%22toc-hId-1620837730%22%20id%3D%22toc-hId-1620837730%22%3EProblema%3C%2FH2%3E%0A%3CP%3EConosci%20un%20po'%20di%20C%2B%2B%20e%20hai%20un'idea%20di%20cosa%20sia%20un%20oggetto%20C%2B%2B%20e%20hai%20bisogno%20dell'introduzione%20di%2020%20minuti%20al%20linguaggio%20di%20scripting%20di%20JMP.%3C%2FP%3E%0A%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--443009121%22%20id%3D%22toc-hId--931319231%22%20id%3D%22toc-hId--931319231%22%3ESoluzione%3C%2FH2%3E%0A%3CUL%3E%0A%3CLI%3ENel%20menu%20Guida%20%C3%A8%20presente%20un%20indice%20di%20script%20JMP.%20Descrive%2C%20insieme%20o%20separatamente%2C%20Funzioni%2C%20DisplayBox%20e%20Oggetti.%20Mentre%20scavi%20pi%C3%B9%20a%20fondo%2C%20usa%20la%20ricerca%20che%20fornisce.%3C%2FLI%3E%0A%3CLI%3EJSL%20non%20ha%20variabili%20digitate%3B%20non%20c'%C3%A8%20modo%20di%20dichiarare%20double%2C%20float%2C%20int%20o%20bool.%20Le%20variabili%20JSL%20contengono%20tutto%20ci%C3%B2%20che%20viene%20loro%20assegnato%2C%20di%20solito%20un%20numero%2C%20una%20matrice%20o%20un%20elenco%2C%20ma%20forse%20un%20DisplayBox%2C%20un'espressione%2C%20una%20funzione%20o%20un%20oggetto.%3C%2FLI%3E%0A%3CLI%3ELe%20strutture%20di%20controllo%20del%20linguaggio%20C%20per%20il%20test%20e%20il%20looping%20(for%2C%20while%2C%20if)%20sono%20molto%20diverse%20dalle%20funzioni%20che%20puoi%20chiamare%20in%20C.%20L'istruzione%20for%20%C3%A8%20qualcosa%20che%20il%20compilatore%20C%20comprende%2C%20ma%20l'istruzione%20print%20%C3%A8%20qualcosa%20che%20comprende%20il%20runtime%20C.%20JSL%20%C3%A8%20diverso%3A%20l'istruzione%20for%20JSL%20%C3%A8%20in%20realt%C3%A0%20una%20funzione%2C%20proprio%20come%20l'istruzione%20if%20JSL%20e%20l'istruzione%20while%20JSL.%20La%20funzione%20che%20esegue%20l'istruzione%20JSL%20for%20si%20chiama%20%22for%22%20e%20accetta%204%20argomenti%2C%20separati%20da%20virgole%20(come%20ci%20si%20aspetterebbe%20che%20appaia%20una%20funzione).%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Efor(%20icount%20%3D%201%2C%20icount%20%26lt%3B%3D%2010%2C%20icount%20%2B%3D%201%2C%20print(%20icount%20)%3B%20wait(1)%3B%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3Esembra%20simile%20al%20ciclo%20C%20for%2C%20ma%20quei%20fastidiosi%20problemi%20con%20virgola%2Fpunto%20e%20virgola%20ti%20daranno%20almeno%20una%20volta.%20Notare%20che%20il%20quarto%20argomento%20%C3%A8%20l'espressione%20JSL%20che%20verr%C3%A0%20eseguita%2010%20volte.%20Si%20noti%20inoltre%20che%20il%20ciclo%20inizia%20da%201%20e%20va%20a%20%26lt%3B%3D%2010.%20In%20C%20quasi%20sicuramente%20inizierai%20da%200%20e%20ti%20fermerai%20su%20%26lt%3B10...%20sae%20numero%20di%20iterazioni%2C%20ma%20basato%20su%200.%20JMP%20preferisce%20la%20base%201%3B%20quasi%20tutta%20l'indicizzazione%20in%20JSL%20%C3%A8%20basata%20su%201%20(ho%20dimenticato%20FORTRAN.)%20L'istruzione%20JSL%20if%20%C3%A8%20una%20funzione%20denominata%20%22if%22%20e%20accetta%20almeno%20due%20argomenti%3A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Eif(%20a%20%26lt%3B%20b%0A%2C%20%2F%2F%20comma%20%0A%20%20%20print(%22a%20is%20less%20than%20b%22)%3B%20x%3D9%3B%0A%2C%20%2F%2F%20comma%20%0A%20%20%20c%20%26lt%3B%20d%0A%2C%20%2F%2F%20comma%20%0A%20%20%20print(%22c%20is%20less%20than%20d%22)%3B%20x%3D10%3B%0A%2C%20%2F%2F%20comma%20%0A%20%20%20print(%22a%20is%20not%20%26lt%3B%20b%20and%20c%20is%20not%20%26lt%3B%20d%22)%3B%20x%3D11%3B%0A)%3B%0A%20%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3EChe%20se%20sembra%20complicato%20solo%20perch%C3%A9%20mostra%20il%20modello%20completo%20che%20la%20funzione%20accetta.%20Puoi%20fermarti%20ovunque%20dopo%20il%20secondo%20argomento.%20Anche%20l'istruzione%20JSL%20while%20%C3%A8%20una%20funzione%20(denominata%20%22while%22)%2C%20che%20accetta%20due%20argomenti.%3C%2FLI%3E%0A%3CLI%3ELe%20espressioni%20sono%20dove%20JSL%20ottiene%20molto%20del%20suo%20potere.%20Un'espressione%20%C3%A8%20un%20po'%20di%20JSL%2C%20forse%20il%204%C2%B0%20argomento%20della%20funzione%20for%20o%20il%202%C2%B0%20argomento%20dell'istruzione%20while.%20Se%20un'espressione%20%C3%A8%20in%20una%20variabile%2C%20pu%C3%B2%20essere%20passata%20a%20una%20funzione%2C%20valutata%20o%20ispezionata%20e%20manipolata.%20JSL%20ha%20una%20funzione%20chiamata%20%22parse%22%20che%20trasforma%20un%20valore%20stringa%20in%20un'espressione.%3C%2FLI%3E%0A%3CLI%3ELe%20matrici%20JSL%2C%20le%20liste%20e%20gli%20array%20associativi%20sono%20oggetti%20contenitore%20di%20alto%20livello%3B%20spesso%20sar%C3%A0%20una%20scelta%20progettuale%20interessante%20quale%20utilizzare%20o%20se%20utilizzare%20una%20tabella%20dati.%20Ognuno%20ha%20punti%20deboli%20e%20punti%20di%20forza%20per%20diversi%20lavori.%3C%2FLI%3E%0A%3CLI%3ELa%20tabella%20dati%20(o%20pi%C3%B9%20tabelle)%20%C3%A8%20un%20oggetto%20che%20puoi%20usare%20in%20JSL%3B%20puoi%20elaborare%20una%20singola%20tabella%20con%20l'istruzione%20forEachRow(espressione)%20(o%20funzione...tutto%20%C3%A8%20una%20funzione%20in%20JSL).%20Con%20pi%C3%B9%20tabelle%20ti%20consigliamo%20di%20utilizzare%20le%20variabili%20JSL%20per%20fare%20riferimento%20a%20diversi%20oggetti%20della%20tabella%20di%20dati%20e%20inviare%20loro%20messaggi.%20I%20messaggi%20JSL%20vengono%20inviati%20a%20un%20oggetto%20con%20l'operatore%20%26lt%3B%26lt%3B%20send.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20open(%22%24sample_data%2Fbig%20class.jmp%22)%3B%0Adt%20%26lt%3B%26lt%3B%20sort(%20by(height)%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CUL%3E%0A%3CLI%3Eil%20messaggio%20o%20metodo%20%22sort%22%20%C3%A8%20solo%20uno%20dei%20tanti%20messaggi%20che%20la%20tabella%20dati%20sa%20come%20gestire.%20Ricorda%20l'indice%20di%20scripting%20al%20punto%201%3B%20elenca%20tutti%20i%20messaggi%20e%20di%20solito%20ha%20un%20esempio.%20La%20tabella%20dati%20elabora%20anche%20le%20richieste%20per%20aprire%20piattaforme%20come%20Distribution.%20Pensa%20alle%20piattaforme%20JSL%20come%20a%20grandi%20subroutine%20utili%20che%20puoi%20mettere%20insieme%20usando%20il%20linguaggio%20di%20scripting%3B%20il%20tuo%20obiettivo%20dovrebbe%20essere%20quello%20di%20fare%20in%20modo%20che%20le%20piattaforme%20facciano%20il%20lavoro%20pesante%20(poich%C3%A9%20sono%20scritte%20in%20C%20%2B%2B%2C%20sono%20molto%20veloci)%20e%20utilizzare%20lo%20scripting%20JSL%20solo%20per%20orchestrare%20la%20tua%20presentazione.%20(Non%20scrivere%20i%20tuoi%20grafici%20di%20distribuzione%20in%20JSL%20senza%20una%20buona%20ragione!)%3C%2FLI%3E%0A%3CLI%3ELe%20presentazioni%2C%20i%20grafici%2C%20le%20tabelle%20e%20l'output%20di%20JSL%20sono%20costruiti%20da%20DisplayBox%20nidificati%20che%20di%20solito%20vengono%20visualizzati%20in%20una%20finestra.%20Un%20DisplayBox%20%C3%A8%20un%20tipo%20speciale%20di%20oggetto%20(e%20riceve%20un%20trattamento%20speciale%20nell'indice%20di%20scripting).%20Puoi%20creare%20display%20personalizzati%20da%20zero%20e%20puoi%20utilizzare%20display%20creati%20da%20piattaforme%20(come%20Distribution).%20Molte%20piattaforme%20hanno%20l'output%20nell'albero%20della%20casella%20di%20visualizzazione%20a%20cui%20%C3%A8%20possibile%20accedere%20tramite%20sottoscrizione.%3C%2FLI%3E%0A%3CLI%3EJSL%20ha%20funzioni%20LoadTextFile%20e%20SaveTextFile%20che%20spostano%20interi%20file%20in%20memoria%2Fdi%20nuovo%20su%20disco.%20Non%20%C3%A8%20possibile%20leggere%2Fscrivere%20pochi%20byte%20alla%20volta.%3C%2FLI%3E%0A%3CLI%3EJSL%20ha%20una%20funzione%20di%20inclusione%20che%20legge%20un%20file%20di%20JSL%20e%20lo%20esegue.%3C%2FLI%3E%0A%3CLI%3EJSL%20ha%20funzioni%20scritte%20dall'utente%2C%20compilate%20dalla%20funzione%20%22funzione%22.%3C%2FLI%3E%0A%3CLI%3EJSL%20ha%20variabili%20locali%20che%20aiutano%20molto%20quando%20si%20scrivono%20progetti%20di%20grandi%20dimensioni.%20Di%20default%20le%20variabili%20sono%20globali%2C%20il%20che%20%C3%A8%20appropriato%20per%20piccoli%20progetti%20e%20test%20unici%2C%20ma%20la%20prima%20volta%20che%20riutilizzi%20%22i%22%20in%20un%20ciclo%20nidificato%2C%20potrebbe%20essere%20il%20momento%20di%20esaminare%20le%20variabili%20locali.%3C%2FLI%3E%0A%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-248644%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20Guida%20per%20programmatori%20C%2B%2B%20a%20JSL%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-248644%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EGrazie!%20L'indice%20di%20scripting%20viene%20creato%20dalle%20stesse%20informazioni%20restituite%20da%20getProperties%20e%20migliorato%20con%20esempi%20per%20casi%20comuni.%20Vorrei%20anche%20che%20ci%20fossero%20pi%C3%B9%20esempi.%20Il%20linguaggio%20ha%20anche%20caratteristiche%20che%20non%20sono%20propriet%C3%A0%20di%20oggetti%20che%20ottengono%20una%20migliore%20copertura%20nel%20libro.%20JMP%20%C3%A8%20migliorato%20rispetto%20agli%20ultimi%20N%20rilasci%20per%20quanto%20riguarda%20la%20produzione%20di%20messaggi%20migliori%20nel%20registro%2C%20a%20volte%20includendo%20anche%20informazioni%20sull'utilizzo.%3C%2FP%3E%3CP%3ELa%20documentazione%2C%20il%20supporto%20tecnico%20e%20i%20team%20di%20sviluppo%20vorrebbero%20avere%20i%20tuoi%20commenti%20su%20tutto%20ci%C3%B2%20che%20necessita%20di%20pi%C3%B9%2Fmigliore%2Fmigliorato%20documento.%20Passare%20attraverso%20il%20supporto%20tecnico%20assicurer%C3%A0%20che%20venga%20monitorato.%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F579%22%20target%3D%22_blank%22%3E%40sheila_loring%3C%2FA%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F4160%22%20target%3D%22_blank%22%3E%20%40shannon_conners%3C%2FA%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F5579%22%20target%3D%22_blank%22%3E%20%40Wendy_Murphrey%3C%2FA%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F494%22%20target%3D%22_blank%22%3E%20%40XanGregg%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-248592%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERi%3A%20Guida%20per%20programmatori%20C%2B%2B%20a%20JSL%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-248592%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3EUna%20nota%20sull'indice%20Scirpting%3A%20%C3%A8%20davvero%20uno%20strumento%20molto%20potente%2C%20con%20la%20sua%20finestra%20di%20scripting%20integrata%20ed%20esempi%20personalizzabili.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMa%20quello%20che%20ho%20trovato%20un%20po'%20difficile%20%C3%A8%20stata%20la%20mancanza%20di%20un%20indice%20di%20sintassi%20completo.%20C'%C3%A8%20davvero%20un%20libro%20in%20pdf%20chiamato%20il%20riferimento%20alla%20sintassi%20JSL%20incluso%20in%20JMP%20ma%20non%20%C3%A8%20completo%20al%20100%25.%20Non%20%C3%A8%20sempre%20possibile%20trovare%20la%20sintassi%20per%20ogni%20argomento%20di%20una%20funzione%20o%20di%20un%20messaggio.%20Spesso%20devi%20usare%20messaggi%20come%20%26lt%3B%3COTTENERE%20propriet%C3%A0%3D%22%22%20e%3D%22%22%20visualizzarle%3D%22%22%20nel%3D%22%22%20registro.%3D%22%22%3E%3C%2FOTTENERE%3E%3C%2FP%3E%3CP%3EHo%20un%20suggerimento%20nella%20lista%20dei%20desideri%20di%20JMP%20per%20questo%2C%20si%20spera%20che%20ottenga%20dei%20complimenti.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
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 bool. JSL variables hold whatever is assigned to them, usually a number, matrix, or list, but maybe a DisplayBox, Expression, Function, or Object.
  • C language control structures for testing and looping (for, while, if) are very different from functions you can call in C. The for statement is something the C compiler understands, but the print statement is something the C runtime understands. JSL is different: the JSL for statement is actually a function, just like the JSL if and the JSL while statement. The function that does the JSL for statement is named "for" and it takes 4 arguments, separated by commas (as you'd expect a function to look).
for( icount = 1, icount <= 10, icount += 1, print( icount ); wait(1); );
  • it looks similar to the C for loop, but those pesky comma/semicolon issues will get you a least once. Note the 4th argument is the JSL Expression that will be executed 10 times. Also note the loop starts at 1 and goes to <= 10. In C you'd almost certainly start at 0 and stop on < 10...sae number of iterations, but 0-based. JMP prefers 1-based; almost all of the indexing in JSL is 1-based (I've forgotten about FORTRAN.) The JSL if statement is a function named "if" and takes at least two arguments:
if( a < b
, // comma 
   print("a is less than b"); x=9;
, // comma 
   c < d
, // comma 
   print("c is less than d"); x=10;
, // comma 
   print("a is not < b and c is not < d"); x=11;
);
 
  •  That if looks complicated only because it shows the full pattern the function accepts. You can stop anywhere after the 2nd argument. The JSL while statement is also a functiuon (named "while"), taking two arguments.
  • Expressions are where JSL gets a lot of its power. An expression is a bit of JSL, perhaps the 4th argument to the for function or the 2nd argument to the while statement. If an expression is in a variable, it can be passed to a function, or it can be evaluated, or it can be inspected and maniplated. JSL has a function named "parse" that turns a string value into an expression.
  • JSL matrices, lists, and associative arrays are high level container objects; often it will be an interesting design choice which to use, or whether to use a data table. Each has weaknesses and strengths for different jobs.
  • The data table (or multiple tables) is an object you can use in JSL; you can process a single table with the forEachRow( expression ) statement (or function...everything is a function in JSL). With multiple tables you'll want to use JSL variables to refer to different data table objects and send them messages. JSL messages are sent to an object with the << send operator.
dt = open("$sample_data/big class.jmp");
dt << sort( by(height) );
  •  the "sort" message, or method, is just one of many messages the data table knows how to handle. Remember the scripting index in point 1; it lists all the messages and usually has an example. The data table also processes requests to open platforms like Distribution. Think of JSL platforms like big useful subroutines that you can string together using the scripting language; your goal should be to get platforms to do the heavy lifting (since they are written in C++, they are very fast) and use JSL scripting just to orchestrate your presentation. (Don't write your own distribution graphs in JSL without a really good reason!)
  • JSL's presentations, graphs, tables, output is built from nested DisplayBoxes that are usually displayed in a window. A DisplayBox is a special kind of object (and gets special treatment in the scripting index.) You can build custom displays from scratch, and you can use displays created from platforms (like Distribution). Many platforms have output in the displaybox tree that you can access by subscripting. 
  • JSL has functions LoadTextFile and SaveTextFile that move entire files into memory/back to disk. There is no read/write a few bytes at a time.
  • JSL has an include function that reads a file of JSL and executes it.
  • JSL has user written functions, compiled by the "function" function.
  • JSL has local variables that help, a lot, when writing large projects. By default variables are global, which is appropriate for tiny projects and one-of-a-kind tests, but the first time you reuse "i" in a nested loop, it might be time to look into local variables.
Comments
bobmorrane

A note on the Scirpting index: It is a very powerful tool indeed, with its integratd Scripting window and customisable examples.

 

But, what I found a bit difficult was the lack of a comprehensive syntax index. There is indeed one pdf book called the JSL syntax reference included in JMP but it is not 100% comprehensive. You can't always find the syntax for every argument of a function or message. You often have to go and use messages such as <<get properties and display that in the log.

I have a suggestion in the JMP wishlist for this, hopefully it gets some kudos.

 

 

 

Thanks! The scripting index is built from the same information that getProperties returns, and enhanced with examples for common cases. I also wish there were more examples. The language also has features that are not properties of objects which get better coverage in the book. JMP has gotten better over the last N releases about producing better messages in the log, sometimes including usage information as well. 

The documentation, technical support, and development teams would love to have your comments about anything that needs more/better/improved doc. Going through tech support will make sure it gets tracked.

@sheila_loring @shannon_conners @Wendy_Murphrey @XanGregg 

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.