How to pass string variable to ComboBox<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />Hello,
I am trying to pass a couple of strings stored in variables to a combo box in a report. This is not working, the combo box just stays at the default value.
Here is the code
Profiler(
Y( Column(3) ),
Profiler(
1,
Term Value(
Name( "Overall Y-A-P20" )(227.01),
Name( "Overall X-B-P2" )(324.6375)
),
Simulator(
1,
Factors(
Name( "Overall Y-A-P20" ) << Random(
distNameOne( 227.01, 0.0241999999999962 )
),
Name( "Overall X-B-P2" ) << Random(
distNameTwo( 324.6375, 0.0300000000000068 )
)
),
Responses( Combined << No Noise )
)
)
)
The variables distNameOne and distNameTwo for example would store the word "Weibull".
I have also confirmed that the variables have the proper string stored using the Show() command.
Does anyone know how to make this work?
Thanks
How to pass string variable to ComboBoxGreat! Thanks it worked!
How to pass string variable to ComboBoxAs Dave mentioned, you can't use a variable to represent a function name directly. For these situations I use a slightly different approach without evalinsert:
distnameone = "Weibull";
distnametwo = "LogNormal";
profile_expr = "
Profiler(
Y( Column( 3 ) ),
Profiler(
1,
Term Value( Name( \!"Overall Y-A-P20\!" )(227.01), Name( \!"Overall X-B-P2\!" )(324.6375) ),
Simulator(
1,
Factors(
Name( \!"Overall Y-A-P20\!" ) << Random(
" || distNameOne || "( 227.01, 0.0241999999999962 ) ),
Name( \!"Overall X-B-P2\!" ) << Random(
" || distNameTwo || "( 324.6375, 0.0300000000000068 )
)
),
Responses( Combined << No Noise )
)
)
)";
eval(parse(profile_expr));
Note that any double quotes inside the expression need to be changed to \!".
Regards,
Peter
Re: How to pass string variable to ComboBoxYou have some code that looks something like this ...
myDist = "Weibull";
Profiler(
Y( :Pred Formula height ),
Profiler(
1,
Term Value( weight( 120 ) ),
Simulator(
1,
Factors( weight << Random( myDist( 3, 134 ) ) ),
Responses( Pred Formula height << Add Random Noise( 1 ) )
)
)
);
The reason the code fails is that JMP evaluates the command without evaluating the variable myDist that has been inserted. There are a number of different approaches to solving this problem, all of which work by substituting values into the expression before it is evaluated.
Below is one approach,
myDist = "Weibull";
Eval(Parse(EvalInsert("\[
Profiler(
Y( :Pred Formula height ),
Profiler(
1,
Term Value( weight( 120 ) ),
Simulator(
1,
Factors( weight << Random( ^myDist^( 3, 134 ) ) ),
Responses( Pred Formula height << Add Random Noise( 1 ) )
)
)
);
]\")));
This is based on the following pattern of code:
Eval(Parse(EvalInsert("\[
// insert JSL-statements here
]\")));
Where JSL-statements represent JSL expressions inclusive of embedded variables using ^name^ notation.
Dave