I have written a jsl script which inputs three positive integers and creates a table. It works fine if the user gives valid inputs. My question is how can I verify the inputs to ensure that they are numeric and integers? Additionally, I would like to have the checking done within the modal dialog so that it will check for invalid input and give the user an opportunity to correct it. Lastly, my cancel button doesn't seem to abort the script.
Any help is appreciated.
//Create training, cross validation and test, column for a covariate input to DOE
New Window( "Create Cross Validation Covariate Table",
<<Modal,
Text Box( "Enter the number of runs for each set" ),
V List Box(
Lineup Box( N Col( 2 ),
Text Box( "Training" ),
ntrain_in = Number Edit Box( 100 ),
Text Box( "Cross Validation" ),
ncv_in = Number Edit Box( 10 ),
Text Box( "Test" ),
ntest_in = Number Edit Box( 10 ),
),
),
Button Box( "OK",
//What do I need to do to put the input checking here and only accept the
//input if valid?
ntrain = ntrain_in << get;
ncv = ncv_in << get;
ntest = ntest_in << get;
),
Button Box( "Cancel",
Throw( "Cancel Button Selected" )
//this doesn't seem to work. Any ideas?
)
);
Show( ntrain, ncv, ntest );
//Need help on checking if valid input.
//each input should be a positive integer in the range [0,large integer]
If( Or( ntrain < 0, ntrain == "" ),
Show( ntrain );
// how to check if numeric?
ntrain = 0;
Throw( "ntrain value not valid" )
;
);
M1 = J( 1, ntrain, 0 );
M2 = J( 1, ncv, 1 );
M3 = J( 1, ntest, 2 );
cv_dt = New Table( "Cross Validation for Covariate input to DOE",
New Column( "validation",
Numeric,
continuous,
Set Values( Concat( Concat( M1, M2, M3 ) ) )
)
);