Automatically change factor settings of a profiler object using a for loopHi all,
I would like to automatically change the factor settings of a profiler object. If I address each factor directly it works as expected:
dt = Open( "$SAMPLE_DATA/Tiretread.jmp" );
obj = dt << Profiler(
Y(
:Pred Formula ABRASION, :Pred Formula MODULUS, :Pred Formula ELONG,
:Pred Formula HARDNESS
),
Desirability Functions( 1 )
);
//works
obj << Term Value("SILICA"(5, Min( -10 ), Max( 6 ), Lock( 1 ), Show( 1 ) ));However, if I want to loop over all factors to change the respective settings, nothing happens.
dt = Open( "$SAMPLE_DATA/Tiretread.jmp" );
obj = dt << Profiler(
Y(
:Pred Formula ABRASION, :Pred Formula MODULUS, :Pred Formula ELONG,
:Pred Formula HARDNESS
),
Desirability Functions( 1 )
);
//does not work
FactorList = {"SILICA", "SILANE"};
for(i=1, i<=n items(FactorList), i++,
Eval(
Eval Expr(
obj << Term Value(
Expr(FactorList[i])( 5, Min( -10 ), Max( 6 ), Lock( 1 ), Show( 1 ) )
)
)
)
);Using
Eval(Eval Expr()) usually solved it when I had similar issues. Sadly, this isn't helping this time.
Thanks for your help!
Automation and ScriptingRe: Automatically change factor settings of a profiler object using a for loopUsing this method appears to work
dt = Open( "$SAMPLE_DATA/Tiretread.jmp" );
obj = dt << Profiler(
Y(
:Pred Formula ABRASION, :Pred Formula MODULUS, :Pred Formula ELONG,
:Pred Formula HARDNESS
),
Desirability Functions( 1 )
);
//does not work
FactorList = {"SILICA", "SILANE"};
for(i=1, i<=n items(FactorList), i++,
Eval(
Parse(
"obj << Term Value(
\!""||FactorList[i]|| "\!"( 5, Min( -10 ), Max( 6 ), Lock( 1 ), Show( 1 ) )
);"
)
)
);Re: Automatically change factor settings of a profiler object using a for loopTo debug your script, you can check what the EvalExpr() part does return
FactorList = {"SILICA", "SILANE"};
i = 1;
term_expr = Eval Expr(obj << Term Value(Expr(FactorList[i])(5, Min(-10), Max(6), Lock(1), Show(1))));
show(term_expr);
it is something like this which is incorrect syntax
term_expr = obj << Term Value("SILICA" << {5, Min(-10), Max(6), Lock(1), Show(1)});
And here is one way of dealing this
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Tiretread.jmp");
obj = dt << Profiler(
Y(:Pred Formula ABRASION, :Pred Formula MODULUS, :Pred Formula ELONG, :Pred Formula HARDNESS),
Desirability Functions(1)
);
terms = {"SILICA", "SILANE"};
For Each({term}, terms,
Eval(Substitute(
Expr(obj << Term Value(_term_(5, Min(-10), Max(6), Lock(1), Show(1)))),
Expr(_term_), Name Expr(AsColumn(dt, term));
));
);