Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
Dib-Dey
Level III

How to reload updating jsl file

I have a jsl file (list.jsl) which has mane lists. Like following. This file is updated by a running a python file called from my GUI.jsl

I'm trying to refresh the tables by calling an action item called MongoDB_table_list_refresh - which is basically trying to reload the updated file.

 

But it is erroring! Any idea how to fix it or any new method?

MongoDB_table_list_refresh = Expr(
	Include( "./GUI_Files/Lists.jsl" );
);

GUI.jsl

Button Box( "   Refresh\!NCollections",
									Caption( "Loading collections from Mongo DB. \!NPlease wait..." );
									Wait( 0 );
									RunProgram( executable( "python" ), options( mongo_path || "update_mongo_tables_lists_file.py" ) );
									Caption( remove );
									MongoDB_table_list_refresh;
									selected_db = Database_name << get selected;
									If( selected_db == "mongo_dev_amr",
										Mongo_Table << Set Items( Mongo_table_list_mongo_dev_amr )
									);
									If( selected_db == "mongo_amr",
										Mongo_Table << Set Items( Mongo_table_list_mongo_amr )
									);

list.jsl

Mongo_table_list_mongo_dev_amr = { "ddr_dv_dev", "ddr_dv_pi", "ddr_internal", "ddr_comp_fsm", "ddr_ac", "ddr_dc" }; // This variable is auto updated by generate_mongo_tables_lists_file.py
Mongo_table_list_mongo_amr = { "ddr_internal" }; // This variable is auto updated by generate_mongo_tables_lists_file.py
2 REPLIES 2
Highlighted
Craige_Hales
Staff (Retired)

Re: How to reload updating jsl file

What is the error message, and which program produced it?

Probably you want to add readfunction("text") to the runprogram arguments. 

Craige
Highlighted
Dib-Dey
Level III

Re: How to reload updating jsl file

We found the solution by incorporating python into it. Get the updated list from python directly as a list and then parse it. In this case, we don't have to refresh and check the file where this list is updated. 

 

output = RunProgram( executable( "python" ),
														 options( mongo_path || "update_mongo_tables_lists_file.py"),
														 readfunction( "text" )
													   );

lines = Words (output, "\!N");
									For( i = 1 , i <= N Items( lines ), i++,
										If( Pat Match( lines[i], "[" ),
											db_str = Word (2, Word (1, lines[i], ":"));
											
											collection_str = Word (1, Word (2, lines[i], "["), "]");
											collection_str = Substitute (collection_str, ",", "");
											collection_str = Substitute (collection_str, "'", "");
											collection_list = Words (collection_str);
											
											if( db_str == "mongo_dev_amr",
												Mongo_table_list_mongo_dev_amr = collection_list );
											if( db_str == "mongo_amr", 
												Mongo_table_list_mongo_amr = collection_list );
											
											selected_db = Database_name << get selected;
											if( db_str == selected_db, 
												Mongo_Table << Set Items( collection_list ); );
										),
									);
Article Labels

    There are no labels assigned to this post.