Subscribe Bookmark RSS Feed

creating a text box and reference data using JSL

fr2007

Community Trekker

Joined:

Jul 3, 2012

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

Joined:

Jun 23, 2011

Solution

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 ),

);

1 REPLY
pmroz

Super User

Joined:

Jun 23, 2011

Solution

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 ),

);