Running a script after making a change. Not working without closing and re-opening the script -why?I am learning JSL and getting a behaviour which I do not think I got when I started. I would like to know if this behaviour is expected or if it is occurring due to a setting change I may have made inadvertently.
I have a simple "main" script which calls a function and another script. When I open JMP fresh and run fresh the main script or the other function/scripts it calls, all of them run fine and produce expected results. However, they do not work when I make a change in any of them (e.g. if I comment the script which is included in the main script, e.g. the last line below). If I close all the open scripts then re-fire them they work again. Coming from other programming languages I do not expect such a behaviour. Any direction is much appreciated
Examples of my mainscript below (I am on JMP13).
//clear log ();<BR />getDataTable = getDataTable4partID("partID","partIDname");
include ("plotallcharts.jsl");
include ("generateJournal.jsl");Commenting the last line above (or if I uncomment clear log ()) i.e.
//clear log ();
getDataTable = getDataTable4partID("partID","partIDname");
include ("plotallcharts.jsl");
//include ("generateJournal.jsl");gives me the following error in the above script
Name Unresolved: getDataTable4partID in access or evaluation of 'getDataTable4partID' , getDataTable4partID( "partID", "partIDname" ) /*###*/
Any direction is much appreciated.
ScriptingRe: Running a script after making a change. Not working without closing and re-opening the script -why?In your example, I do not see where you define the function
getDataTable4partID
JSL is an interpreted language, and requires the creation of any items referenced in the code, prior to the calling of it. It is not a compiled language, which first passes through all of the code and identifying functions etc. Now what can be confusion is that once the function is defined, it will remain in memory and available until it is cleared with a
clear symbols();<BR />// or<BR />clear globals();
If you follow through your code with this in mind, you may see why your JSL cannot find the function.
Re: Running a script after making a change. Not working without closing and re-opening the script -why?Thanks @txnelson.
Here is the function
getDataTable4partID
Are you suggesting that I use
clear symbols();
// clear globals();
at the top of my main script?
If yes, then I have tired it without any change in behaviour.
Also, I forgot to mention above that when the main script does not run (after making a change in it) and I need to restart JMP to make the script run as expected again, I also need to run the function my main script is calling, once, without which my main script does not run. This is clearly an undesirable behaviour and I worry that I am not doing things properly.
Re: Running a script after making a change. Not working without closing and re-opening the script -why?Your should start your whole script with:
Names Default to Here( 1 );
Clear Symbols();
This will stabilize the Namespace environment and clear out all of the previous values, thus starting you fresh each time you run the code from the top.
Re: Running a script after making a change. Not working without closing and re-opening the script -why?Thanks @txnelson. OK so this is what I did and now my scripts and functions are not working even after closing and re-running or after restarting JMP.
My main script
Names Default to Here( 1 );
Clear Symbols();
getDataTable = getDataTable4partID("partID","partIDname");
include ("plotallcharts.jsl");
include ("generateJournal.jsl");My function is (without database details)
Names Default to Here (1)
getDataTable4PartID = Function({PartID}, {dtTemp},
dtTemp = Open Database("connectionstring",
"select '" || PartID || "' as value
from dual",
PartID
);
return(dtTemp);
);and my script
plotallcharts.jsl;
also has its fist line as
Names Default to Here (1)
I am still getting the error
Name Unresolved: getDataTable4partID in access or evaluation of 'getDataTable4partID' , getDataTable4partID( "partID", "partIDname" ) /*###*/
but sometimes the log is not showing anything upon running the main script.