This website uses Cookies. Click Accept to agree to our website's cookie use as described in our Privacy Policy. Click Preferences to customize your cookie settings.
This version requires the user to commit the changes to the number.
Names Default to Here( 1 );
last = eon = 0;
New Window( "Only Seven",
Outline Box( "Enter EON",
Line Up Box( N Col( 2 ),
Text Box( "System EON:" ),
neb = Number Edit Box( eon,
<< Set Integer Only( 1 ),
<< Set Minimum( 0 ),
<< Set Tip( "Enter an integer number with no more than 7 digits"),
<< Set Function( // called when user commits data entry
Function( { self },
new = self << Get;
If( Length( Char( new ) ) > 7,
self << Set( last ),
last = new
);
);
)
)
)
)
);
Names Default To Here(1);
nw = New Window("Example",
Lineup Box(N Col(2),
Text Box("Set to max value on COMMIT:"),
Number Edit Box(
.
, 10
, << Set Maximum(9999999)
, << Set Exclude Maximum(0)
, << Set Integer Only(1)
),
Text Box("Set to last COMMITTED value on COMMIT:"),
cb = Context Box(
box:last_val = .;
Number Edit Box(
.
, 10
, << Set Function(function({this},
If((this << get) >= 10000000,
this << set(box:last_val)
,
box:last_val = this << get;
)
))
)
),
Text Box("Throw on COMMIT"),
cb = Context Box(
box:last_val = .;
Number Edit Box(
.
, 10
, << Set Function(function({this},
If((this << get) >= 10000000,
this << set(box:last_val);
Throw("No values longer than 7 digits allowed");
,
box:last_val = this << get;
)
))
)
),
Text Box("Set to last changed value on change and break focus:"),
cb = Context Box(
box:last_val = .;
Number Edit Box(
.
, 10
, << Set Number Changed(function({this, val},
If((val) >= 10000000,
this << set(box:last_val);
box:mb << Set Focus(1); // to break focus from number edit box
,
box:last_val = val;
)
))
),
Unlineup Box(box:mb = Mouse Box());
)
)
);
Names Default to Here( 1 );
last = eon = 0;
New Window( "Only Seven",
Outline Box( "Enter EON",
Line Up Box( N Col( 2 ),
Text Box( "System EON:" ),
neb = Number Edit Box( eon,
<< Set Integer Only( 1 ),
<< Set Minimum( 0 ),
<< Set Tip( "Enter an integer number with no more than 7 digits")
<< Set Number Changed(
Function( { self, number },
If( Length( Char( number ) ) > 7,
self << Set( last ),
last = number
);
);
)
)
)
)
)
I modified the code as shown below, but still no success. Do you think its a big in JMP software?
Names Default to Here( 1 );
last = eon = 0;
New Window( "Only Seven",
Outline Box( "Enter EON",
Line Up Box( N Col( 2 ),
Text Box( "System EON:" ),
neb = Number Edit Box( eon,
<< Set Integer Only( 1 ),
<< Set Minimum( 0 ),
<< Set Tip( "Enter an integer number with no more than 7 digits")
<< Set Number Changed(
Function( { self, number },
If( Length( Char( number ) ) > 7,
self << Set( last ),
last = number
);
);
),
<< Set Max Length(7) // Limit the number of digits to 7
)
)
)
)
This is a modified version of the example of set number changed() and get number changed() in the Scripting Index. I think this gets you pretty close to your target:
Names Default To Here( 1 );
New Window( "Example",
numBox = Number Edit Box(
.,
10,
<< set number changed(
Function( { thisBox, value }, /* put my value into my sibling's display */
if( length( char( value ) ) > 7,
// > 7 digits
thisBox << set( . );
( thisBox << sib ) << settext( "Too many digits" ),
// <= 7 digits
( thisBox << sib ) << settext( char( value ) )
)
)
)
),
Text Box( "" )/* here's the sibling box, waiting to show a message */
);
numBox << get number changed()
This version requires the user to commit the changes to the number.
Names Default to Here( 1 );
last = eon = 0;
New Window( "Only Seven",
Outline Box( "Enter EON",
Line Up Box( N Col( 2 ),
Text Box( "System EON:" ),
neb = Number Edit Box( eon,
<< Set Integer Only( 1 ),
<< Set Minimum( 0 ),
<< Set Tip( "Enter an integer number with no more than 7 digits"),
<< Set Function( // called when user commits data entry
Function( { self },
new = self << Get;
If( Length( Char( new ) ) > 7,
self << Set( last ),
last = new
);
);
)
)
)
)
);
Names Default To Here(1);
nw = New Window("Example",
Lineup Box(N Col(2),
Text Box("Set to max value on COMMIT:"),
Number Edit Box(
.
, 10
, << Set Maximum(9999999)
, << Set Exclude Maximum(0)
, << Set Integer Only(1)
),
Text Box("Set to last COMMITTED value on COMMIT:"),
cb = Context Box(
box:last_val = .;
Number Edit Box(
.
, 10
, << Set Function(function({this},
If((this << get) >= 10000000,
this << set(box:last_val)
,
box:last_val = this << get;
)
))
)
),
Text Box("Throw on COMMIT"),
cb = Context Box(
box:last_val = .;
Number Edit Box(
.
, 10
, << Set Function(function({this},
If((this << get) >= 10000000,
this << set(box:last_val);
Throw("No values longer than 7 digits allowed");
,
box:last_val = this << get;
)
))
)
),
Text Box("Set to last changed value on change and break focus:"),
cb = Context Box(
box:last_val = .;
Number Edit Box(
.
, 10
, << Set Number Changed(function({this, val},
If((val) >= 10000000,
this << set(box:last_val);
box:mb << Set Focus(1); // to break focus from number edit box
,
box:last_val = val;
)
))
),
Unlineup Box(box:mb = Mouse Box());
)
)
);