We’re asking you to select a content label when starting a new topic in the Discussions area. Read more to find out why.
Choose Language Hide Translation Bar
Highlighted
abdulj
Level IV

How to pass string variable to ComboBox

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

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
David_Burnham
Super User

Re: How to pass string variable to ComboBox

You 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

-Dave

View solution in original post

3 REPLIES 3
Highlighted
David_Burnham
Super User

Re: How to pass string variable to ComboBox

You 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

-Dave

View solution in original post

Highlighted
pmroz
Super User

How to pass string variable to ComboBox

As 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

Highlighted
abdulj
Level IV

How to pass string variable to ComboBox

Great! Thanks it worked!