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
Pim
Pim
Level III

Is it possible to add Text Edit Boxes to all scripts in a Journal using JSL

Hi JMP community,

 

I was wondering if it would be possible to script the generation of a journal containing selected tables and/or figures including a Text Edit Box for each table/figure.

 

I came across an Add-in that is doing part of what I would like to do: https://community.jmp.com/t5/JMP-Add-Ins/Run-All-Table-Scripts/ta-p/42863

 

I’m only interested in the Tiled Report option but would like the addition of a Text Edit box for all selected scripts because I would like to add comments to them. I was able to add a Text Edit Box at the start and at the end of the Journal but I can’t seem to figure out (if and) how to add them for every script. The amount of selected scripts will change based on the amount of figures needed for the journal.

 

For my needs, I took parts of the Run All Table Scripts Add-in I could use and tried to change it. So far without success. Does anyone have suggestions how to add Text Edit Boxes to all scripts in a journal?

 

//This script is part of the Run All Table Scripts Add-in written by nickholmes13: https://community.jmp.com/t5/JMP-Add-Ins/Run-All-Table-Scripts/ta-p/42863.

Names Default To Here( 1 );
dt = Current Data Table();
appName = "Run All Table Scripts";

If (IsEmpty(dt),
 Try(dt=Open(), Show("No data table is open so the Data Table Script Runner tool could not execute."));
);
If(IsEmpty(dt),
	Stop();
);

Wait(.5);

dtTitle = dt << Get Window Title();//Get title of data table
allScripts = dt <<Get Table Script Names();//Get names of all scripts saved in data table

//Error message displayed when no scripts are available in data table
numScripts = N Items(allScripts);
If(
	numScripts ==0,
	win = New Window(appName|| "- No Scripts",
		Border Box (Left( 10 ), Right( 10 ), Top( 10 ), Bottom( 10 ),
			Text Box("There are no table scripts to run for '"||dtTitle||"'.", << Set Font Style( "Bold" )
			)
		),
		H List Box(
			Spacer Box(),
			Border Box(Right( 15 ),Button Box("Close", win << Close Window )
			)
		)
	),

//This script is run when the 'run' button is pressed
onRun = Function({reportView, scriptsTR},
	nScriptsTR = N Items(scriptsTR);
	scriptErrors ={};
	For(i=1, i<=nScriptsTR, i++,
		If( nScriptsTR == 1,
			dt << Run Script(scriptsTR[i]),
			If (i==1,
				window = New Window(dtTitle||" Reports", << Journal,
					lb = Lineup Box(Ncol(1),
						Panel Box("Comment", Text Edit Box("", Set Width (600))),//Panel Box with Text Edit Box at start of journal.
					
						Try(report = (dt << Run Script(scriptsTR[i])), //I would like to add a Text Edit Box to all scripts run in this line.
						Insert Into(scriptErrors, "'"||scriptsTR[i]||"': script did not run to completion.")
						),					
					),
					
					Panel Box("Conclusion/Discussion", Text Edit Box("", Set Width (600))),//Panel Box with Text Edit Box at end of journal
				),
				
				Try(
					lb << Append(Try(report = (dt << Run Script(scriptsTR[i])),
					Insert Into(scriptErrors, "'"||scriptsTR[i]||"': script did not run to completion."))
					), ""
				);
			);
		);
		If(reportView ==2,
			Try(report << Report View ("Summary"), "")
		)
	);
	
	If(N Items(scriptErrors)!=0,
		errorText = "";
		For(i=1, i<=NItems(scriptErrors), i++,
			errorText = errorText||"-- "||scriptErrors[i]||"\!n"
		);
		Win = New Window("Script Errors",
			Border Box(Left( 10 ), Right( 10 ), Top( 10 ), Bottom( 10 ),
				Lineup Box(Ncol(1),
					Text Box(errorText),
					H List Box(
						Spacer Box(),
						Button Box("Okay", Win << Close Window)
					)
				)
			)
		)
	)
);

popup = New Window(appName,
			Border Box (Left( 10 ), Right( 10 ), Top( 10 ), Bottom( 10 ),
				Lineup Box(Ncol(1),
					Text Box("This utility will attempt to run all of the table scripts saved to <b>"||dtTitle||"</b>. Be aware that all table scripts will be run, even if they do not create reports. Also note that applications created in table scripts will always appear in a separate window. \!n",
					<< Markup),
					
					Panel Box ("Which table scripts would you like to run?",
						V List Box(
							scriptsTR = Check Box(allScripts, << Set All(1)),
						),
						H List Box(
							Button Box("Check All", scriptsTR << Set All(1)),
							Button Box ("Check None", scriptsTR << Set All(0))
						),
						Spacer Box(Size(0,10)),
						Text Box("Report View"),
						rType = Radio Box({"Detailed", "Summary"})
					),
					H List Box(
						Button Box ("Cancel", popup << Close Window()),
						Spacer Box(),
						Button Box ("Run",		reportView = rType << Get();
												scriptsTR = scriptsTR << Get Selected();
												onRun(reportView, scriptsTR);
												popup << Close Window())
					)
				)
			)	
		 );
	
	popup<<Set Auto Stretching(0,0);
	
);

I hope it is allowed to use and change the add-in provided in the link above (it was not locked). If not, I will delete this post. Credits for the Run All Table Scripts for: nickholmes13.

 

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Is it possible to add Text Edit Boxes to all scripts in a Journal using JSL

One option would be to edit the else statement inside the for loop in onRun function. See how the else statement has been built/modified:

 

				If(i == 1,
					window = New Window(dtTitle || " Reports",
						<<Journal,
						lb = Lineup Box(N Col(1),
							Panel Box("Comment", Text Edit Box("", Set Width(600))), //Panel Box with Text Edit Box at start of journal.
					
							Try(
								report = (dt << Run Script(scriptsTR[i])), //I would like to add a Text Edit Box to all scripts run in this line.
								Insert Into(
									scriptErrors,
									"'" || scriptsTR[i] || "': script did not run to completion."
								)
							),

						), 
					
						Panel Box("Conclusion/Discussion", Text Edit Box("", Set Width(600))), //Panel Box with Text Edit Box at end of journal
					)
				, //else
				
					Try(
						lb << Append(
							Try(
								Lineup Box(N Col(1),
									Panel Box("Comment", Text Edit Box("", Set Width(600))), //Panel Box with Text Edit Box at start of journal.
									report = (dt << Run Script(scriptsTR[i]))
								),
								Insert Into(
									scriptErrors,
									"'" || scriptsTR[i] || "': script did not run to completion."
								)
							)
						),
						""
					)
				)
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Is it possible to add Text Edit Boxes to all scripts in a Journal using JSL

One option would be to edit the else statement inside the for loop in onRun function. See how the else statement has been built/modified:

 

				If(i == 1,
					window = New Window(dtTitle || " Reports",
						<<Journal,
						lb = Lineup Box(N Col(1),
							Panel Box("Comment", Text Edit Box("", Set Width(600))), //Panel Box with Text Edit Box at start of journal.
					
							Try(
								report = (dt << Run Script(scriptsTR[i])), //I would like to add a Text Edit Box to all scripts run in this line.
								Insert Into(
									scriptErrors,
									"'" || scriptsTR[i] || "': script did not run to completion."
								)
							),

						), 
					
						Panel Box("Conclusion/Discussion", Text Edit Box("", Set Width(600))), //Panel Box with Text Edit Box at end of journal
					)
				, //else
				
					Try(
						lb << Append(
							Try(
								Lineup Box(N Col(1),
									Panel Box("Comment", Text Edit Box("", Set Width(600))), //Panel Box with Text Edit Box at start of journal.
									report = (dt << Run Script(scriptsTR[i]))
								),
								Insert Into(
									scriptErrors,
									"'" || scriptsTR[i] || "': script did not run to completion."
								)
							)
						),
						""
					)
				)
-Jarmo
Pim
Pim
Level III

Re: Is it possible to add Text Edit Boxes to all scripts in a Journal using JSL

Thank you jthi, this is what I was looking for!