Understanding/organizing user-defined functionsHi 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
Automation and ScriptingRe: Understanding/organizing user-defined functionsJMP Scripting Guide can provide some guidelines (or at least tell what Include and Function do)
- Advanced Functions (jmp.com)
- 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)).
Re: Understanding/organizing user-defined functionsAlso this topic will be somewhat covered today in Scripters Club Learning Sessions | JMP (Making your JSL more Efficient).
Re: Understanding/organizing user-defined functionsThank you, this is what I was looking for! I was looking at several JMP references but none of them gave any details