- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Turning Private data tables on and off
In 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!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Turning Private data tables on and off
You 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Turning Private data tables on and off
I 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(0);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Turning Private data tables on and off
You 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Turning Private data tables on and off
Visible 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Turning Private data tables on and off
What precisely are the benefits of using private tables? Saving memory?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Turning Private data tables on and off
Saving 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Turning Private data tables on and off
Jim 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Turning Private data tables on and off
Agreed @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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Turning Private data tables on and off
Thanks 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Turning Private data tables on and off
If 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.