Information Lookup WindowHello,
As a new .jsl user I've attempted to learn by producing a small script to pull data out of the big class sample data table given a user input.
For most of the problems I've encountered the solutions could be found on these discussion boards but I have an few extra things I'd like to add that I can't find any information on.
- If the user enters an incorrect name (i.e. if no matching rows are found) how would I script an alert window to pop-up and inform the user of this?
- Instead of opening a subset data table, is it possible to print the returned cell value to the UI window itself (below the search and cancel buttons)? or if not, to a new window similar to the alert window described above.
- Could any optimisations be made or general improvements to the script?
Thanks in advance for any help,
No7
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp", "Invisible" );
dt << Clear Selected;
cols = dt << getColumnNames( "String" );
delcols = {"name"};
For( i = 1, i <= N Items( delcols ), i++,
Remove From( cols, As List( Loc( cols, delcols[i] ) ) )
);
lookup_script = Expr(
myName = Uppercase( name1 << get text );
If( myName != "",
match_rows = dt << get rows where( :name == myName )
);
dt << subset( columns( cols[cb << get] ), rows( match_rows ) );
);
UIwin = New Window( "Big Class Age/Height Lookup",
Show Menu( 0 ),
Show Toolbars( 0 ),
//<<MODAL></MODAL>Re: Information Lookup Window@uday_guntupalli Fantastic the following worked;
If( Nrows(match_rows) == 0,
Text Box( "Serial Not Found."),
Thanks for your quick response!
Re: Information Lookup Window@JMPUserNumber7,
Try N Rows() if it is a row vector N Cols() if it is a col vector.
Re: Information Lookup Window@uday_guntupalli Thanks very much, this is exactly what I was looking for, I wasn't aware of the Append function in this case!
I've updated the script to return a string when no name is entered and altered your edits slightly. However I cannot get the following to work
If(IsEmpty(match_rows),
Text Box("The name you looked up does not exist")From reading here it's because JMP is returning an array instead of the desired text. Any ideas of a work around?
Thanks again.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp", "Invisible" );
dt << Clear Selected;
cols = dt << getColumnNames( "String" );
delcols = {"name"};
For( i = 1, i <= N Items( delcols ), i++,
Remove From( cols, As List( Loc( cols, delcols[i] ) ) )
);
lookup_script = Expr(
myName = Uppercase( name1 << get text );
If( myName == "",
VL1 << Append( H List Box( Text Box( "Please enter a name.", <<BULLET point=""></BULLET>
Re: Information Lookup Window@JMPUserNumber7,
Try doing something like this:
dt = Open( "$SAMPLE_DATA/Big Class.jmp", "Invisible" );
dt << Clear Selected;
cols = dt << getColumnNames( "String" );
delcols = {"name"};
For( i = 1, i <= N Items( delcols ), i++,
Remove From( cols, As List( Loc( cols, delcols[i] ) ) )
);
lookup_script = Expr(
myName = Uppercase( name1 << get text );
If( myName != "",
match_rows = As List(dt << get rows where( :name == myName ))
);
// dt << subset( columns( cols[cb << get] ), rows( match_rows ) );
// My Edit
VL1 << Append(
H List Box(
If(IsEmpty(match_rows),
Text Box("The information you looked up does not exist")
,
Text Box("The information you looked up is" || char(dt[match_rows,cols[cb<<GET></GET>