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
Whiz
Level I

JMP 15 Modal Window error getting data

Hi, I'm new to JMP scripting and recently we are going to migrate from JMP12 to JMP15.

I'm having problems with some of the scripts that used to work in JMP12, but don't work now in JMP15.

I understand from some of the posts here that it could be because the data is cleared when the modal window is closed and the information is gone.

However I'm not sure how to edit the script such that it can work in JMP15.

Any help is appreciated.

The script is as below:

Clear globals();
Clear log();

//constants
secondsInDay = 24*60*60;
secondsInWeek = secondsInDay*7;
linecount = 8;
Linename = {"1D2-CTA1","1D2-CTB1","1D2-CTA2","1D2-CTB2","1D2-CTA3","1D2-CTB3","1D2-CTA4","1D2-CTB4"};

db = New Window ("HJT Testers Data", 
	<< Modal,
			
			Line up Box(
		NCol(2),
		Text Box("Start Date MM/DD/YYYY"),
		sd = Text Edit Box (mdyhms(Today()-1*24*60*60)),
		Text Box("End Date MM/DD/YYYY"),
		ed = Text Edit Box (mdyhms(Today()))
		),
			Line up Box(
					NCol(2),
					Text Box ("Line"),
					lineAll = Checkbox("+/- all", 0 , if(LineAll<<get(1),For(i = 1, i <= lineCount,i++,line<<set(i,1));,For(i = 1, i <= lineCount, i++ , line<<set(i,0));)),
					line = Checkbox(Linename, <<Set(6, 1));
			),
			
		Line up Box (
		NCol(3),
		Button Box("Last 2 Hours",sd<<Set Text(Format(Date Increment(Today(),"Hour",-2,"Actual"),"m/d/y h:m:s"));ed<<Set Text(Format(Today(),"m/d/y h:m:s"));),
		Button Box("Last 4 Hours",sd<<Set Text(Format(Date Increment(Today(),"Hour",-4,"Actual"),"m/d/y h:m:s"));ed<<Set Text(Format(Today(),"m/d/y h:m:s"));),
		Button Box("Last 24 Hours Day Report",sd<<Set Text(Format(Date Increment(Date Increment(Today(),"Day",-1),"Hour",8),"m/d/y h:m:s"));ed<<Set Text(Format(Date Increment(Date Increment(Today(),"Day",0),"Hour",8),"m/d/y h:m:s"));),	
		Button Box("Today",sd<<Set Text(Format(Date Increment(Today(),"Day",0),"m/d/y h:m:s"));ed<<Set Text(Format(Date Increment(Today(), "Day", 1),"m/d/y h:m:s"));),
		Button Box("Yesterday",sd<<Set Text(Format(Date Increment(Today(), "Day", -1),"m/d/y h:m:s"));ed<<Set Text(Format(Date Increment(Today(),"Day",0),"m/d/y h:m:s"));),
		Button Box("Past 7 Days Report",sd<<Set Text(Format(Date Increment(Date Increment(Today(),"Day",-7),"Hour",8),"m/d/y h:m:s"));ed<<Set Text(Format(Date Increment(Date Increment(Today(),"Day",0),"Hour",8),"m/d/y h:m:s"));),
			),

		Button Box( "OK", 
		startdate = sd << gettext;
		enddate = ed << gettext;
	
	),
	bbC = Button Box( "Cancel"
	);
);

 
If(db == {Button(-1)}, Throw("User cancelled script."));


lineString = "";
//define the line
For(i = 1, i <= lineCount, i++, If(line << get(i), if(lineString == "",lineString = lineString||" and ([EquipmentID] = '"||linename[i]||"' ", lineString = lineString||" or [EquipmentID] = '"||linename[i]||"' ")));
if (lineString == "", lineString = "", lineString = lineString ||")");


//An SQL query string that is always selected.	
standardDataString = "select *";



//filter for time range
timeFilterTableName = "[ms_creationdate]";
timeRangeString =timeFilterTableName||" > '"||startdate||"' and "||timeFilterTableName||" < '"||enddate||"'";

After this, the script will then perform a SQL query to get information using the aforementioned standardDataString, timeRangeString, and lineString.

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
pmroz
Super User

Re: JMP 15 Modal Window error getting data

The problem occurs if you do not check any of the checkboxes, and leave the default one checked.  The section of code that initializes myline is never run.  This code fixes the problem:

Clear Globals();
Clear Log();

//constants
secondsInDay = 24 * 60 * 60;
secondsInWeek = secondsInDay * 7;
linecount = 8;
Linename = {"1D2-CTA1", "1D2-CTB1", "1D2-CTA2", "1D2-CTB2", "1D2-CTA3", "1D2-CTB3", "1D2-CTA4",
"1D2-CTB4"};

db = New Window( "HJT Testers Data",
	<<Modal, 
			
	Lineup Box( N Col( 2 ),
		Text Box( "Start Date MM/DD/YYYY" ),
		sd = Text Edit Box( MDYHMS( Today() - 1 * 24 * 60 * 60 ) ),
		Text Box( "End Date MM/DD/YYYY" ),
		ed = Text Edit Box( MDYHMS( Today() ) )
	),
	Lineup Box( N Col( 2 ),
		Text Box( "Line" ),
		lineAll = Check Box(
			"+/- all",
			0,
			If( LineAll << get( 1 ),
				For( i = 1, i <= lineCount, i++,
					line << set( i, 1 )
				),
				For( i = 1, i <= lineCount, i++,
					line << set( i, 0 )
				)
			)
		),
		line = Check Box( Linename, <<Set( 6, 1 ),
		)
	), 
			
	Lineup Box( N Col( 3 ),
		Button Box( "Last 2 Hours",
			sd << Set Text(
				Format( Date Increment( Today(), "Hour", -2, "Actual" ), "m/d/y h:m:s" ) );
			ed << Set Text( Format( Today(), "m/d/y h:m:s" ) );
		),
		Button Box( "Last 4 Hours",
			sd << Set Text(
				Format( Date Increment( Today(), "Hour", -4, "Actual" ), "m/d/y h:m:s" ) );
			ed << Set Text( Format( Today(), "m/d/y h:m:s" ) );
		),
		Button Box( "Last 24 Hours Day Report",
			sd << Set Text(
				Format(
					Date Increment( Date Increment( Today(), "Day", -1 ), "Hour", 8 ),
					"m/d/y h:m:s"
				)
			);
			ed << Set Text(
				Format(
					Date Increment( Date Increment( Today(), "Day", 0 ), "Hour", 8 ),
					"m/d/y h:m:s"
				)
			);
		),
		Button Box( "Today",
			sd << Set Text( Format( Date Increment( Today(), "Day", 0 ), "m/d/y h:m:s" ) );
			ed << Set Text( Format( Date Increment( Today(), "Day", 1 ), "m/d/y h:m:s" ) );
		),
		Button Box( "Yesterday",
			sd << Set Text( Format( Date Increment( Today(), "Day", -1 ), "m/d/y h:m:s" ) );
			ed << Set Text( Format( Date Increment( Today(), "Day", 0 ), "m/d/y h:m:s" ) );
		),
		Button Box( "Past 7 Days Report",
			sd << Set Text(
				Format(
					Date Increment( Date Increment( Today(), "Day", -7 ), "Hour", 8 ),
					"m/d/y h:m:s"
				)
			);
			ed << Set Text(
				Format(
					Date Increment( Date Increment( Today(), "Day", 0 ), "Hour", 8 ),
					"m/d/y h:m:s"
				)
			);
		), 

	), 

	Button Box( "OK",
		myLine = Index( 1, lineCount );
		For( i = 1, i <= lineCount, i++,
			myLine[i] = line << get( i )
		);

		startdate = sd << gettext;
		enddate = ed << gettext;
	
	),
	bbC = Button Box( "Cancel" )
);
 
If( db == {Button( -1 )},
	Throw( "User cancelled script." )
);

lineString = "";
//define the line
For( i = 1, i <= lineCount, i++,
	If( myLine[i],
		If( lineString == "",
			lineString = lineString || " and ([EquipmentID] = '" || linename[i] || "' ",
			lineString = lineString || " or [EquipmentID] = '" || linename[i] || "' "
		)
	)
);
If( lineString == "",
	lineString = "",
	lineString = lineString || ")"
);

//An SQL query string that is always selected.	
standardDataString = "select *";

//filter for time range
timeFilterTableName = "[ms_creationdate]";
timeRangeString = timeFilterTableName || " > '" || startdate || "' and " || timeFilterTableName
 || " < '" || enddate || "'";

View solution in original post

4 REPLIES 4
Highlighted
txnelson
Super User

Re: JMP 15 Modal Window error getting data

The issue is the referencing of the Checkbox() display object called "line".  You are attempting to access the object after the modal window has been closed in JMP 15.  Apparently, in JMP 12, the object remained accessable longer.  Below is the simple fix to the issue. It works in both JMP 12 and 15:

Clear Globals();
Clear Log();

//constants
secondsInDay = 24 * 60 * 60;
secondsInWeek = secondsInDay * 7;
linecount = 8;
Linename = {"1D2-CTA1", "1D2-CTB1", "1D2-CTA2", "1D2-CTB2", "1D2-CTA3", "1D2-CTB3", "1D2-CTA4", "1D2-CTB4"};

db = New Window( "HJT Testers Data",
	<<Modal, 
			
	Lineup Box( N Col( 2 ),
		Text Box( "Start Date MM/DD/YYYY" ),
		sd = Text Edit Box( MDYHMS( Today() - 1 * 24 * 60 * 60 ) ),
		Text Box( "End Date MM/DD/YYYY" ),
		ed = Text Edit Box( MDYHMS( Today() ) )
	),
	Lineup Box( N Col( 2 ),
		Text Box( "Line" ),
		lineAll = Check Box(
			"+/- all",
			0,
			If( LineAll << get( 1 ),
				For( i = 1, i <= lineCount, i++,
					line << set( i, 1 )
				),
				For( i = 1, i <= lineCount, i++,
					line << set( i, 0 )
				)
			)
		),
		line = Check Box(
			Linename,
			<<Set( 6, 1 ),
			myLine = Index( 1, lineCount );
			For( i = 1, i <= lineCount, i++,
				myLine[i] = line << get( i )
			);
		)
	), 
			
	Lineup Box( N Col( 3 ),
		Button Box( "Last 2 Hours",
			sd << Set Text( Format( Date Increment( Today(), "Hour", -2, "Actual" ), "m/d/y h:m:s" ) );
			ed << Set Text( Format( Today(), "m/d/y h:m:s" ) );
		),
		Button Box( "Last 4 Hours",
			sd << Set Text( Format( Date Increment( Today(), "Hour", -4, "Actual" ), "m/d/y h:m:s" ) );
			ed << Set Text( Format( Today(), "m/d/y h:m:s" ) );
		),
		Button Box( "Last 24 Hours Day Report",
			sd << Set Text( Format( Date Increment( Date Increment( Today(), "Day", -1 ), "Hour", 8 ), "m/d/y h:m:s" ) );
			ed << Set Text( Format( Date Increment( Date Increment( Today(), "Day", 0 ), "Hour", 8 ), "m/d/y h:m:s" ) );
		),
		Button Box( "Today",
			sd << Set Text( Format( Date Increment( Today(), "Day", 0 ), "m/d/y h:m:s" ) );
			ed << Set Text( Format( Date Increment( Today(), "Day", 1 ), "m/d/y h:m:s" ) );
		),
		Button Box( "Yesterday",
			sd << Set Text( Format( Date Increment( Today(), "Day", -1 ), "m/d/y h:m:s" ) );
			ed << Set Text( Format( Date Increment( Today(), "Day", 0 ), "m/d/y h:m:s" ) );
		),
		Button Box( "Past 7 Days Report",
			sd << Set Text( Format( Date Increment( Date Increment( Today(), "Day", -7 ), "Hour", 8 ), "m/d/y h:m:s" ) );
			ed << Set Text( Format( Date Increment( Date Increment( Today(), "Day", 0 ), "Hour", 8 ), "m/d/y h:m:s" ) );
		), 

	), 

	Button Box( "OK",
		startdate = sd << gettext;
		enddate = ed << gettext;
	
	),
	bbC = Button Box( "Cancel" )
);

 
If( db == {Button( -1 )},
	Throw( "User cancelled script." )
);


lineString = "";
//define the line
For( i = 1, i <= lineCount, i++,
	If( myLine[i],
		If( lineString == "",
			lineString = lineString || " and ([EquipmentID] = '" || linename[i] || "' ",
			lineString = lineString || " or [EquipmentID] = '" || linename[i] || "' "
		)
	)
);
If( lineString == "",
	lineString = "",
	lineString = lineString || ")"
);


//An SQL query string that is always selected.	
standardDataString = "select *";



//filter for time range
timeFilterTableName = "[ms_creationdate]";
timeRangeString = timeFilterTableName || " > '" || startdate || "' and " || timeFilterTableName || " < '" || enddate || "'";

 

Jim
Highlighted
Whiz
Level I

Re: JMP 15 Modal Window error getting data

Hi, I tried to copy your solution and run it, but it says "Name Unresolved: myLine in access or evaluation of 'myLine', myLine.

 

Is it because the myLine is referenced somewhere but again it's no longer accessible?

 

Thanks for your help.

Highlighted
pmroz
Super User

Re: JMP 15 Modal Window error getting data

The problem occurs if you do not check any of the checkboxes, and leave the default one checked.  The section of code that initializes myline is never run.  This code fixes the problem:

Clear Globals();
Clear Log();

//constants
secondsInDay = 24 * 60 * 60;
secondsInWeek = secondsInDay * 7;
linecount = 8;
Linename = {"1D2-CTA1", "1D2-CTB1", "1D2-CTA2", "1D2-CTB2", "1D2-CTA3", "1D2-CTB3", "1D2-CTA4",
"1D2-CTB4"};

db = New Window( "HJT Testers Data",
	<<Modal, 
			
	Lineup Box( N Col( 2 ),
		Text Box( "Start Date MM/DD/YYYY" ),
		sd = Text Edit Box( MDYHMS( Today() - 1 * 24 * 60 * 60 ) ),
		Text Box( "End Date MM/DD/YYYY" ),
		ed = Text Edit Box( MDYHMS( Today() ) )
	),
	Lineup Box( N Col( 2 ),
		Text Box( "Line" ),
		lineAll = Check Box(
			"+/- all",
			0,
			If( LineAll << get( 1 ),
				For( i = 1, i <= lineCount, i++,
					line << set( i, 1 )
				),
				For( i = 1, i <= lineCount, i++,
					line << set( i, 0 )
				)
			)
		),
		line = Check Box( Linename, <<Set( 6, 1 ),
		)
	), 
			
	Lineup Box( N Col( 3 ),
		Button Box( "Last 2 Hours",
			sd << Set Text(
				Format( Date Increment( Today(), "Hour", -2, "Actual" ), "m/d/y h:m:s" ) );
			ed << Set Text( Format( Today(), "m/d/y h:m:s" ) );
		),
		Button Box( "Last 4 Hours",
			sd << Set Text(
				Format( Date Increment( Today(), "Hour", -4, "Actual" ), "m/d/y h:m:s" ) );
			ed << Set Text( Format( Today(), "m/d/y h:m:s" ) );
		),
		Button Box( "Last 24 Hours Day Report",
			sd << Set Text(
				Format(
					Date Increment( Date Increment( Today(), "Day", -1 ), "Hour", 8 ),
					"m/d/y h:m:s"
				)
			);
			ed << Set Text(
				Format(
					Date Increment( Date Increment( Today(), "Day", 0 ), "Hour", 8 ),
					"m/d/y h:m:s"
				)
			);
		),
		Button Box( "Today",
			sd << Set Text( Format( Date Increment( Today(), "Day", 0 ), "m/d/y h:m:s" ) );
			ed << Set Text( Format( Date Increment( Today(), "Day", 1 ), "m/d/y h:m:s" ) );
		),
		Button Box( "Yesterday",
			sd << Set Text( Format( Date Increment( Today(), "Day", -1 ), "m/d/y h:m:s" ) );
			ed << Set Text( Format( Date Increment( Today(), "Day", 0 ), "m/d/y h:m:s" ) );
		),
		Button Box( "Past 7 Days Report",
			sd << Set Text(
				Format(
					Date Increment( Date Increment( Today(), "Day", -7 ), "Hour", 8 ),
					"m/d/y h:m:s"
				)
			);
			ed << Set Text(
				Format(
					Date Increment( Date Increment( Today(), "Day", 0 ), "Hour", 8 ),
					"m/d/y h:m:s"
				)
			);
		), 

	), 

	Button Box( "OK",
		myLine = Index( 1, lineCount );
		For( i = 1, i <= lineCount, i++,
			myLine[i] = line << get( i )
		);

		startdate = sd << gettext;
		enddate = ed << gettext;
	
	),
	bbC = Button Box( "Cancel" )
);
 
If( db == {Button( -1 )},
	Throw( "User cancelled script." )
);

lineString = "";
//define the line
For( i = 1, i <= lineCount, i++,
	If( myLine[i],
		If( lineString == "",
			lineString = lineString || " and ([EquipmentID] = '" || linename[i] || "' ",
			lineString = lineString || " or [EquipmentID] = '" || linename[i] || "' "
		)
	)
);
If( lineString == "",
	lineString = "",
	lineString = lineString || ")"
);

//An SQL query string that is always selected.	
standardDataString = "select *";

//filter for time range
timeFilterTableName = "[ms_creationdate]";
timeRangeString = timeFilterTableName || " > '" || startdate || "' and " || timeFilterTableName
 || " < '" || enddate || "'";

View solution in original post

Highlighted
Whiz
Level I

Re: JMP 15 Modal Window error getting data

Thanks! This works now!

Article Labels

    There are no labels assigned to this post.