cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
ScottMullin
Level I

Understanding/organizing user-defined functions

Hi folks,

I'm looking for examples and references to look at in the manuals as appropriate.

I'm a longtime JMP user but have marginal experience with JSL. I'm writing a script to automate the extraction and compilation of a bunch of legacy data. I am having reasonable luck with the mechanics of each step, but my code is becoming a long series of *stuff* and I need to modularize it by writing functions and then calling those. However, I am misunderstanding how JSL works on some level. I see the "function" and "include" objects, but I'm having a hard time finding good examples of basic usage of these. For example, I made one function and put it at the end of my code, but I couldn't call it earlier in the code. I suppose that means JMP is reading the script sequentially.

what are the proper and best practices for doing this?

I expect this is a basic question, but any explanations are most welcome.

Regards,
Scott

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Understanding/organizing user-defined functions

JMP Scripting Guide can provide some guidelines (or at least tell what Include and Function do)

  1. Advanced Functions (jmp.com)
  2. Include a Script (jmp.com) (can be used to evaluate JSL from other scripts, for example functions which can then be used)

Functions, expressions, variables (and everything) has to be defined before they can be used. Generally I define all my functions and some of my variables at "initialization" so at the beginning of script. Remember to start your script with Names Default To Here(1); unless you manage everything with namespaces to avoid variable collisions and polluting global namespace too much (Advanced Scoping and Namespaces (jmp.com)).

-Jarmo

View solution in original post

3 REPLIES 3
jthi
Super User

Re: Understanding/organizing user-defined functions

JMP Scripting Guide can provide some guidelines (or at least tell what Include and Function do)

  1. Advanced Functions (jmp.com)
  2. Include a Script (jmp.com) (can be used to evaluate JSL from other scripts, for example functions which can then be used)

Functions, expressions, variables (and everything) has to be defined before they can be used. Generally I define all my functions and some of my variables at "initialization" so at the beginning of script. Remember to start your script with Names Default To Here(1); unless you manage everything with namespaces to avoid variable collisions and polluting global namespace too much (Advanced Scoping and Namespaces (jmp.com)).

-Jarmo
jthi
Super User

Re: Understanding/organizing user-defined functions

Also this topic will be somewhat covered today in Scripters Club Learning Sessions | JMP (Making your JSL more Efficient).

-Jarmo
ScottMullin
Level I

Re: Understanding/organizing user-defined functions

Thank you, this is what I was looking for! I was looking at several JMP references but none of them gave any details