How to get Button Box Script to have evaluated expressionHi,
I'm trying to create an automated addition of button boxes that will script point to individual Outline Boxes (as an example with Scroll Window or close) - I manage to get the expression built through a For loop that inserts the name of the script items in the list successfully, but when I go to have the button boxes each have a unique script, they instead hold the name of the expression 'buttonclickexpr' as the script.
How do I get the script in the expression evaluated and placed correctly as a written command that the button box will run on click?
//an example of how the window could appear
report_win=new window("test", content_VLB=V List Box(), Outline Box("Example: Distribution"), Outline Box("Example: Multivariate"));
//example of the variable that would store the name of scripts that created the OBs
script_new={"Distribution", "Multivariate", "Profiler"};
//the for loop to correctly setup the expression with the correct section name and add a button
For( i = 1, i <= N Items( script_new ), i++,
buttonclickexpr = Expr(
report_win << Scroll Window(
report_win[Outline Box( sectionName)]
)
);
Substitute Into( buttonclickexpr, Expr(sectionName), Char("Example: " ||script_new[i]) );
write(buttonclickexpr);
// Add a button to the list
content_VLB<<APPEND></APPEND>
Automation and ScriptingRe: How to get Button Box Script to have evaluated expressionyou can use Eval(Eval Expr()).
//an example of how the window could appear
report_win = New Window( "test",
content_VLB = V List Box(),
Scroll box (Size(20,1500)),
Outline Box( "Example: Distribution" ),
Scroll box (Size(20,1500)),
Outline Box( "Example: Multivariate" )
);
//example of the variable that would store the name of scripts that created the OBs
script_new = {"Distribution", "Multivariate", "Profiler"};
//the for loop to correctly setup the expression with the correct section name and add a button
For( i = 1, i <= N Items( script_new ), i++,
buttonclickexpr = Expr(
report_win << Scroll Window( report_win[sectionName ] );
Caption(sectionName)
);
Substitute Into( buttonclickexpr, Expr( sectionName ), Char( "Example: " || script_new[i] ) );
Write( buttonclickexpr );
// Add a button to the list
Eval (Eval Expr(content_VLB << append( Button Box( "Go to " || script_new[i], Expr(Name Expr(buttonclickexpr)))) ));
);
In OutlineBox("tag"), the tag is the HelperKey of the OutlineBox. To access the Outline box via the title, you can directly use the title [without OutlineBox()).
Details can be found in Re: Expression Handling in JMP: Tipps and Trapdoors
| use |
|
| Name Expr() |
... to retrieve the expression that is stored in the name buttonclickexpr |
| Expr() |
... to mark the code - such that Eval Expr() can find it |
| Eval Expr() |
... to find Expr() and evaluate it |
| Eval() |
... to evaluate the whole expression after the previous steps. |
Re: How to get Button Box Script to have evaluated expressionAn alternative approach : Substitute()
[already used to adjust the buttonclickexpr *)]
Both steps on one:
For each ({title}, script_new ,
myExpr = Expr(
content_VLB << append( Button Box( "Go to " || title,current report() << Scroll Window( current report()[_sectionName_ ] )));
);
Eval(Substitute (Name Expr(myExpr), Expr( _sectionName_ ), "Example: " || title ));
);
| use |
|
| Substitute() |
... like Substitute for String - but keep in mind that the arguments get evaluated! This is why you have to use ... |
| Name Expr() |
... to retrieve the expression that is stored in the name myExpr - without evaluating it!!! |
| Expr() |
... to protect _sectionName_ from getting evaluated |
| Eval() |
... to evaluate the whole expression after the previous steps. |
*) Other than Substitute. Substitute Into() does not evaluate its first argument.