cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar

How do I make a date/time box fuction with alternative text inputs?

The script I'm working on has this function that creates a datebox with a default value as the argument, and if the user enters something that can't be recognized as a date, it sets the text back to that default value.  I want to add a feature where if you type certain keywords into the datebox, it will trigger it to do a certain behavior.  For example if the user types "yesterday" it will set the date/time to the beginning of the previous day.

I can't figure out how to make the function check for these key words before it converts the text back to the default value due to not being a proper date.  Any pointers on how to accomplish this?

(using JMP 17, but ideally it would work with the newer versions as well)

 

timeBox = Function( {time},   
	Eval(
		Substitute(
		
			NameExpr( NumberEditBox(
				time,
				10, //width
				<< SetFunction( Function( {self}, {},
					If( IsMissing(self << get), self << Set(Eval(dummy)) );
				) ),
				<< Set Format( Format( "m/d/y h:m:s", 23, 0 ) );
			) ),
			
			Expr( dummy ), 
			
			time
			
		)
	);
);

timeEntryWindow = NewWindow( << Modal, 
	PanelBox( "Start Time", startTimeBox = timeBox( Today() - 12*60*60 ) )
);

 

1 REPLY 1
jthi
Super User

Re: How do I make a date/time box fuction with alternative text inputs?

As it is NUMBER edit box it "can" only accept numbers. Start with something very simple and test it out in different ways (you will end up with missing values if you input text)

 

Names Default To Here(1);

nw = new window("",
	neb = Number Edit Box(.)
);

neb << Set Function(function({this},
	show(this << get)
));
/*
neb << Set Number Changed(function({this, val},
	show(this << get);
	show(val);
));
*/

You could create dropdown/button to set the yesterday value OR you could use text edit box and build custom calendar box / number edit box with that.

 

-Jarmo

Recommended Articles