cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. ET on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Dib-Dey
Level III

How to auto-run attached scripts on a table pulled from database

Following code will attach all jsl scripts in c:\work directory to the table dt. 

 

Do you know any function/command which can also make it auto-run on the table?

 

dt = Current Data Table();
dir = "C:\work";
fileNames = Files In Directory( dir );
if (dir!="",
	For( iFile = 1, iFile <= N Items( fileNames ), iFile++,
			filename = fileNames[iFile];
			show(filename);
			
			If( Ends With( filename, ".jsl" ),
				file_path = dir || "\" || filename;
				show(file_path);
				x = Load Text File( file_path );
				Eval( Parse( "dt << new script(filename," || x || ")" ) );
			);
		);
);
1 REPLY 1
txnelson
Super User

Re: How to auto-run attached scripts on a table pulled from database

The

dt << run scripts( filename );

will run the script after it has been saved to the data table.

dt = Current Data Table();
dir = "C:\work";
fileNames = Files In Directory( dir );
if (dir!="",
	For( iFile = 1, iFile <= N Items( fileNames ), iFile++,
			filename = fileNames[iFile];
			show(filename);
			
			If( Ends With( filename, ".jsl" ),
				file_path = dir || "\" || filename;
				show(file_path);
				x = Load Text File( file_path );
				Eval( Parse( "dt << new script(filename," || x || ")" ) );
				dt << run scripts( filename );
			);
		);
);

If you want all of the scripts run whenever the data table is opened, you can add a table script called OnOpen where you could specify to run each of the table scripts.

Jim

Recommended Articles