cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
fr2007
Level II

creating a text box and reference data using JSL

iam trying to create a text box that asks where it asks for "Enter the required Code" . The user enters the code and clicks on 'Search' button. Then the code entered has to be searched in the script.

example:-

kw1="";

dial_wind =New Window("Select Profit Center",
Text Box(""),
Text Box("Enter you profit center code."),
Text Box(""),
keyword1 = Text Edit Box("",<< set width (200), <<script(kw1=keyword1<<get text)),
Text Box(" "),
  Button Box( "Search", search_script),
  Text Box(" "),
     );

search_script=Expr(if (kw1=="",
match_rows = dt << get rows where(:Revision == 0 & Column2 == kw1));
dt << subset(columns(), rows(match_rows));

so with the above code, if I type any value for kw1 in the text box, it should be lookedup in the match_rows function .

Can some one help me with the above code? Some how kw1 is not being referrenced in column2.

1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Re: creating a text box and reference data using JSL

The callback script for the keyword1 text edit box only gets executed if you type something in the box and then tab out or hit CR.  Easier to just put it all into the search_script expression.  Also, you had kw1=="" when you needed kw1 != "".

This code works:

dt = current data table();

search_script = Expr(

    kw1 = (keyword1 << get text );

    If( kw1 != "",

        match_rows = dt << get rows where( :Revision == 0 & :Column2 == kw1 )

    );

    dt << subset( columns(), rows( match_rows ) );

);

dial_wind = New Window( "Select Profit Center",

    Text Box( "Enter your profit center code." ),

    keyword1 = Text Edit Box( "", <<set width( 200 ) ),

    Button Box( "Search", search_script ),

);

View solution in original post

1 REPLY 1
pmroz
Super User

Re: creating a text box and reference data using JSL

The callback script for the keyword1 text edit box only gets executed if you type something in the box and then tab out or hit CR.  Easier to just put it all into the search_script expression.  Also, you had kw1=="" when you needed kw1 != "".

This code works:

dt = current data table();

search_script = Expr(

    kw1 = (keyword1 << get text );

    If( kw1 != "",

        match_rows = dt << get rows where( :Revision == 0 & :Column2 == kw1 )

    );

    dt << subset( columns(), rows( match_rows ) );

);

dial_wind = New Window( "Select Profit Center",

    Text Box( "Enter your profit center code." ),

    keyword1 = Text Edit Box( "", <<set width( 200 ) ),

    Button Box( "Search", search_script ),

);