Hi, I have been trying for a while to write a code in JSL where depending on the value of certain variable, the graph obtained from graph builder changes.
My particular example right now is pretty simple, I have a check box and depending on the user selection (checked/unchecked) I want to add or remove groups into the graph using the local filter. Here is a very simple example
dt = Open( "$SAMPLE_DATA/Analgesics.jmp" );
// Open Analgesics
cb = 1; // Predefined value<BR /><BR />// Check box to Remove group A from the graph
usw = New Window("Ignore A?", << Modal,
//Check Box defaulted to checked ignore
checkIgnore = check box({"Ignore A?"},
<< Set(1,1),
cb = checkIgnore << Get())
);
// Answer to Cancel or close buttons
If( usw["button"] == -1, throw("User cancelled") );
show(cb); // I can see how the value of cb changes between 0 and 1
nw = New Window( "Example Report",
// Box plot with dots
dot_box_plot = dt << Graph Builder(
Show Control Panel( 0 ),
Show Legend( 0 ),
Show Title( 0 ),
Variables( X(:drug ), Y( :pain ), Color(:drug ) ),
Elements( Position( 1, 1 ), Points( X, Y, Legend( 2 ) ), Box Plot( X, Y, Legend( 3 ) ) ),
Elements( Position( 2, 1 ), Points( X, Y, Legend( 2 ) ), Box Plot( X, Y, Legend( 3 ) ) ),
SendToReport( Dispatch( {}, "X title", TextEditBox, {Set Text( "" )} ) ),
/* This is the part that I'd like to make interactive
to keep or remove A-group from the plot depending on
user selection */
if(cb == 1,
Local Data Filter(
Close Outline( 1 ),
Add Filter( columns( :drug ),
Where( :Drug != "A" )
)
)
)
)
);As you can see, there should be something wrong in my part with the if statement because nothing changes, the plot keeps all groups. And of course, when I remove only the IF() part, my plot ignores the group A.
I would be very thankful for any suggestions.
Hi Jim, I need help with my most advances script yet. in a nut shell, the script will ask the use to enter a register number between 1-5
the script does nothing when I add a while statement or if statement. if add one expression only without the while or if statement it works fine.
but I am trying to half works for multiple registers, I normally get files for individual registers and wanted to use a single script to cover all 5 variety.
thanks in advance.
Sam
full script below
w = New Window( "Enter Register number to Analyze", // opens a window with a title and this content...
Border Box( top( 20 ), bottom( 20 ), Left( 160 ), Right( 160 ), // window dressing
V List Box( // V and H lists nest to organize the display boxes
H Center Box( Text Box( "Type in Register number below" ) ), // a second title, centered
Spacer Box( size( 1, 10 ) ), // a little vertical space
// H List Box( Text Box( "value 1: " ), Number Edit Box( v1 ) ), // data entry
H List Box( Text Box( "Enter Register Num:" ), Register_Num_teb = Text Edit Box( "", <
Spacer Box( size( 1, 10 ) ), // a little vertical space
H Center Box( // center the button
Button Box( "Continue", // this script runs when the button is pressed...
Register = Register_Num_teb << get text();
// make a new table with the values...
///////////////////////////////////////////////////////////////////////////////////////////starting the loop
While( Register == 1,
dothis = Expr(
New Column( "start_time", Numeric, Continuous, Formula( (:rise_time_scope_v_vout * 1000) / 0.8 ) )
);
dothis;
dt << MoveSelectedColumns( {:start_time}, After( :Register1_active ) );
dothis = Expr(
New Column( "SoftStart_Accuracy%",
Numeric,
Continuous,
Formula( ((:Register1_tsoftstart - :start_time) / :Register1_tsoftstart) * 100 )
)
);
dothis;
dt << MoveSelectedColumns( {:SoftStart_Accuracy%}, After( :start_time ) );
);
While( Register == 2,
dothis = Expr(
New Column( "start_time", Numeric, Continuous, Formula( (:rise_time_scope_v_vout * 1000) / 0.8 ) )
);
dothis;
dt << MoveSelectedColumns( {:start_time}, After( :Register2_active ) );
dothis = Expr(
New Column( "SoftStart_Accuracy%",
Numeric,
Continuous,
Formula( ((:Register2_tsoftstart - :start_time) / :Register2_tsoftstart) * 100 )
)
);
dothis;
dt << MoveSelectedColumns( {:SoftStart_Accuracy%}, After( :start_time ) );
);
While( Register == 3,
dothis = Expr(
New Column( "start_time", Numeric, Continuous, Formula( (:rise_time_scope_v_vout * 1000) / 0.8 ) )
);
dothis;
dt << MoveSelectedColumns( {:start_time}, After( :Register3_active ) );
dothis = Expr(
New Column( "SoftStart_Accuracy%",
Numeric,
Continuous,
Formula( ((:Register3_tsoftstart - :start_time) / :Register3_tsoftstart) * 100 )
)
);
dothis;
dt << MoveSelectedColumns( {:SoftStart_Accuracy%}, After( :start_time ) );
);
While( Register == 4,
dothis = Expr(
New Column( "start_time", Numeric, Continuous, Formula( (:rise_time_scope_v_vout * 1000) / 0.8 ) )
);
dothis;
dt << MoveSelectedColumns( {:start_time}, After( :Register4_active ) );
dothis = Expr(
New Column( "SoftStart_Accuracy%",
Numeric,
Continuous,
Formula( ((:Register4_tsoftstart - :start_time) / :Register4_tsoftstart) * 100 )
)
);
dothis;
dt << MoveSelectedColumns( {:SoftStart_Accuracy%}, After( :start_time ) );
);
While( Register == 5,
dothis = Expr(
New Column( "start_time", Numeric, Continuous, Formula( (:rise_time_scope_v_vout * 1000) / 0.8 ) )
);
dothis;
dt << MoveSelectedColumns( {:start_time}, After( :Register5_active ) );
dothis = Expr(
New Column( "SoftStart_Accuracy%",
Numeric,
Continuous,
Formula( ((:Register5_tsoftstart - :start_time) / :Register5_tsoftstart) * 100 )
)
);
dothis;
dt << MoveSelectedColumns( {:SoftStart_Accuracy%}, After( :start_time ) );
);
///////////////////////////////////////////////////////////////////////////////////////////
// optionally, close the dialog. Or, you might want to run it again...
w << closeWindow; // just the dialog, not the report
)
)
)
)
);