How to use the value of my For Each loop to generate new table scriptsI am looping over existing data table scripts and creating a duplicate of each script with some alterations.
I want to insert those table script names into the generated table scripts.
The output I get just inserts the word "script" in my generated table scripts instead of the actual string value in scriptList
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
scriptList = dt << Get Table Script Names;
For Each({script}, scriptList,
If ((!Contains(scriptList, "Run "||script)),
dt << New Script("Run "||script,dt=Current DataTable();w=eval(dt << get table property((script)));w << set window title((script)));
);
);
Automation and ScriptingRe: How to use the value of my For Each loop to generate new table scriptsSome expression handling combined with Insert one expression into another using Eval Insert, Eval Expr, Parse, and Substitute should work. Here is one example:
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
For Each({script_name}, dt << Get Table Script Names,
If((!Contains(script_name, "Run " || script_name)),
script_expr = dt << Get Script(script_name);
Eval(Substitute(
Expr(
dt << New Script("Run " || _script_name_,
Local({w},
w = _new_script_;
w << set window title(_script_name_)
)
);
),
Expr(_script_name_), script_name,
Expr(_new_script_), Name Expr(script_expr)
))
)
);Re: How to use the value of my For Each loop to generate new table scriptsthank you that is indeed working nicely
Re: How to use the value of my For Each loop to generate new table scriptsHi, I guess I didn't specify as such in my original question, but your solution did change the behaviour of my script since it copies the target script code into the new script. I wanted to keep the reference only to the original script. Here's the final script I'm using, maybe other people might find it useful.
dt = Current Data Table();
scriptList = dt << Get Table Script Names;
For Each( {script_name}, scriptList,
If( (!Contains( script_name, "Run" ) & !Contains( scriptList, "Run " || script_name )),
Eval(
Substitute(
Expr(
dt << New Script(
"Run " || script_name,
dt = Current Data Table();
w = Eval( dt << get table property( script_placeholder ) );
w << set window title( script_placeholder );
)
),
Expr(script_placeholder), Char(script_name)
)
)
)
);Re: How to use the value of my For Each loop to generate new table scriptsJMP 14 no work.
Re: How to use the value of my For Each loop to generate new table scriptsFor Each() function is a new feature in JMP 16.