Turning Private data tables on and offIn keeping many of my scripts clean, I use 'private' quite a lot. However, if I am troubleshooting a script, having tables as private gets in the way and I need to comment out and hopefully remember to uncomment as I make changes to see if the changes work.
Is there a way, or does JMP already have a global way to turn private tables on or off? In my head I could take the time to make duplicates of my code with and without the private and tie it to a test variable, but that doesn't seem like the best answer.
Wasn't sure if there were any ideas out there on how to do that. Thanks!
Automation and ScriptingRe: Turning Private data tables on and offThat's excellent, Vince! It's similar to what I ended up doing, but it's much more elegant in allowing the dataview to go both ways.
Re: Turning Private data tables on and offAgreed @Craige_Hales and @txnelson on those points. @Ressel, the main reason I usually opt for private tables is when I have a script that makes changes/updates/etc many tables. If they are left alone, they can be very flashy on the screen in front of a user as the windoes come up, go away, etc. If they are invisible the user may see a lot of activity in the Window list which also can be a distraction.
I opt for private tables most of the time as they allow for the cleanest interface for the user with only the necessary visual steps being visual. Depending on the number of tables and the users computer, the RAM benefits are also a gain in overall speed.
Re: Turning Private data tables on and offJim is correct; a private table has no OS window structure created, while an invisible table has a window that is not displayed. There might be a small CPU and memory savings which might add up if there are 100s or 1000s of tables.
The only time I've used private was when I wrote FileSnapper and wanted the application to be quietly running without disturbing the JSL environment for any other JSL that runs. You mostly can't detect the private data table at all. It does have a column name that intrudes a little.
Re: Turning Private data tables on and offNathan, is this helpful at all?
Names default to here( 1 );
dt = open("$SAMPLE_DATA\Big Class.jmp");
privateTable = Function({bool,dt},{default local},
table_name = dt << Get Name;
If(!bool & !(dt << HasDataView), // no table but you want one
print("making "||table_name||" public");
dt << New Data View;
Return(dt);
, // elif
bool & dt << HasDataView, // you have a table but want it private
print("making "||table_name||" private");
dt_sub = dt << Subset( All rows, Selected columns only( 0 ), "private" );
close(dt, no save);
dt_sub << Set Name(table_name);
return(dt_sub);
, // else just return what's given
print("passthrough");
return(dt);
)
);
dt = privateTable(1, dt); // should make it private
wait(2);
dt = privateTable(1, dt); // should do nothing
wait(2);
dt = privateTable(0, dt); // should do make it visible
wait(2);
dt = privateTable(1, dt); // should do make it private again
Re: Turning Private data tables on and offSaving RAM is the benefit. A Private table does not create any visible objects. All of those objects would have to be mapped to memory if they are visible.
Re: Turning Private data tables on and offWhat precisely are the benefits of using private tables? Saving memory?
Re: Turning Private data tables on and offYes! That's definitely on my radar. I have a library of functions/utilities I keep a lot of that stuff on hand (and distribute), and shifting to the custom function aspect is one plan long term for many of the more dynamic functions.
Re: Turning Private data tables on and offIf you need that function often, you might benefit from creation of Custom function Create Custom Functions, Transforms, and Formats (jmp.com) .This way you can also see the custom function directly from scripting index.
Re: Turning Private data tables on and offThanks everyone! I ended up doing the following which, although not ideal, should work pretty well. I created a function and have a variable at the top of my script to basically turn private on / off
seePrivateTables = 1;
unprivatizeTable = Function({bool,tableName},{default local},
If(bool == 1,
tableName << New Data View;
Return(tableName)
,
Return(tableName)
)
);
// ... various code
dt1 = dt << Summary(.... , private);
dt1 = unprivatizeTable(seePrivateTables, dt1);As long as I remember to call that function when I create new tables, I should be able to turn private tables on and off in bulk.
Re: Turning Private data tables on and offVisible and invisible tables are tracked by JMP. You can keep an eye on them in the home window, for example. Private tables are tracked only by the code that creates them. If you fail to close a private table before overwriting the JSL variable holding its handle, the table is still in memory but unreachable. It will be closed when JMP terminates. (Window->CloseAllDataTables can't find the private tables and won't close them.)
I'm also pretty sure JMP does not expose a way to turn a visible or invisible table private. You can turn a private table to an invisible one, if you have the handle, like this:
dtA = Open( "$SAMPLE_DATA/Big Class.jmp", private );
// getting the data box makes it invisible
b = dtA << New Data Box();
// then show window makes it visible
dtA << Show Window;
Unfortunately, the invisible keyword is a keyword and can't be passed as a variable, at least to open(). Not sure about subset, etc. Probably the best you can do is add a call to a user function that does something like above after each point where you create or open a table.
Re: Turning Private data tables on and offYou might be able to make private table visible by using << New Data View. I'm not 100% what this does in this context, but it seems to make private tables visible and I have used it for debugging:
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp", private);
wait(2);
dt << New Data View;
no idea how to make it private again, but << Show Window(0); will make it invisible at least.
Re: Turning Private data tables on and offI am not aware of being able to turn Private on and off, since it would require on-the-fly building of all of the display objects in memory. However, you can use the Show Window message to display/hide normal or invisible data tables.
data table("Daily Blood Pressure")<<SHOW window=""></SHOW>