- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
How to determine if a data table is already opened?
This is how I used to do it before JMP 8:
tableIsOpen = Function( {tname},
{dt, rv = 0},
Try(
dt = Data Table( tname );
rv = 1;
);
rv;
);
This does not work in JMP verison 8 because DataTable function will open a file dialog if the table is not opened already. User can always press "cancel" but it's annoying.
Thanks for any help.
Tommy
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to determine if a data table is already opened?
Created:
Feb 6, 2009 10:58 AM
| Last Modified: Jul 22, 2018 4:44 PM
(4445 views)
| Posted in reply to message from tommst 02-04-2009
You can loop through all the open tables by passing a number to Data Table() and compare names.
tableIsOpen = Function( {tname},
{rv = 0, i},
For( i = 1, i < N Table() + 1 & rv == 0, i++,
If( Lowercase( Data Table( i ) << Get Name ) == Lowercase( tname ),
rv = 1
)
);
rv;
);
edit: with a "<=" option
tableIsOpen = Function( {tname},
{rv = 0, i},
For( i = 1, i <= N Table() & rv == 0, i++,
If( Lowercase( Data Table( i ) << Get Name ) == Lowercase( tname ),
rv = 1
)
);
rv;
);
(The forum software really doesn't like less than or equal, which is why I use plain less than and added 1.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: How to determine if a data table is already opened?
Thanks for the code. I'm trying it out now.
I wish there's a more straight forward way of checking for opened data file.
I wish there's a more straight forward way of checking for opened data file.