cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
ConfidenceOwl94
Level III

How to continue Script execution if table doesn't exist.

I have my main data table broke down in to few tables using subset function. Then I am doing some operations and trying to merge them back using the update function. But sometime time I only have one table and sometimes 2 tables. How can I tell script to continue if second table doesn't exist. 

 

// Update data tables
Data Table( "Material A" ) << Update(
With( Data Table( "Material B" ) ),
Match Columns( :SN = :SN )

 

How can I tell script that if Material A or Material B table not exist, still continue execution. 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How to continue Script execution if table doesn't exist.

You could use Try-statement or you could check if those tables exist before updating. Personally I would perform a check instead of relying on Try. Also usually it is better to use variables to store references to tables instead of relying on the table names.

 

Edit: Using Try would look something like this (https://www.jmp.com/support/help/en/17.2/#page/jmp/throw-and-catch-exceptions.shtml)

Try(
	Data Table("Big Class") << Update(
		With(Data Table("Big Class Families")),
		Match Columns(:name = :name)
	)
);

and check for table names

tablelist = Get Data Table List() << get name;
// Only join if both are found
If(Contains(tablelist, "Big Class") & Contains(tablelist, "Big Class Families"),
	Data Table("Big Class") << Update(
		With(Data Table("Big Class Families")),
		Match Columns(:name = :name)
	)
);
-Jarmo

View solution in original post

3 REPLIES 3
jthi
Super User

Re: How to continue Script execution if table doesn't exist.

You could use Try-statement or you could check if those tables exist before updating. Personally I would perform a check instead of relying on Try. Also usually it is better to use variables to store references to tables instead of relying on the table names.

 

Edit: Using Try would look something like this (https://www.jmp.com/support/help/en/17.2/#page/jmp/throw-and-catch-exceptions.shtml)

Try(
	Data Table("Big Class") << Update(
		With(Data Table("Big Class Families")),
		Match Columns(:name = :name)
	)
);

and check for table names

tablelist = Get Data Table List() << get name;
// Only join if both are found
If(Contains(tablelist, "Big Class") & Contains(tablelist, "Big Class Families"),
	Data Table("Big Class") << Update(
		With(Data Table("Big Class Families")),
		Match Columns(:name = :name)
	)
);
-Jarmo
ConfidenceOwl94
Level III

Re: How to continue Script execution if table doesn't exist.

Thanks for the solutions and advice to use variables to store references to tables instead of relying on the table names.

jthi
Super User

Re: How to continue Script execution if table doesn't exist.

If you use variables then you could also use Is Empty(dtref)

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
Try(dt2 = Open("$SAMPLE_DATA/Big Class Families"));
Show(Is Empty(dt), Is Empty(dt2));

but you might have to use other methods, depending where you are getting your tables (you can figure out a way to use Try() if nothing else seems to work).

-Jarmo