JSL: Launch platform dialog for user input, then modify reportBanging my head against the wall, there must be a simple way to do this but I'm at a loss.
Here's my desired scenario:
1) Running the script should bring up the "Distribution" platform launch dialog, so the user can make selections
2) On clicking OK, return a handle to the resulting report so it can be addressed and modified.
I can achieve the same result, laboriously, by creating a custom modal dialog, parsing the results, and passing them to the Distribution platform. But what I want is to allow the user to run the regular Distribution launch dialog.
Any ideas?
Re: JSL: Launch platform dialog for user input, then modify reportJordan,
Here is an example from the scripting guide using action().
Or will this do what you want?
Stan
Re: JSL: Launch platform dialog for user input, then modify reportHi Jordan,
Run this and scroll to the bottom of the report to see if this does what you want:
Names Default To Here(1);
dt = astable(J(20,1,Random Uniform()));
grabHandle = expr(
distHandle = current report();
doTheRest
);
dt << distribution(action(grabHandle));
doTheRest = expr(
for(i=1, i<=3, i++, distHandle[outlinebox(1)] << append(textbox("Yay!")))
);
Notice that since "doTheRest" is an expression called by grabHandle, it won't run until the user hits the OK button. Otherwise, the 3 appends will try to run immediately; this results in an error, because distHandle will be undefined, as the Distribution report will not yet have been created. So, you'll want to have anything dependent upon / downstream of the Distribution report wrapped in an expression, which gets called inside whatever expression is the argument of the Action() function.
Thanks @stan_koprowski, for mentioning the Action () function... I did not know of its existence.
Cheers,
Brady
Re: JSL: Launch platform dialog for user input, then modify reportThanks @brady_brady this is exactly what I needed. Couldn't get the Action() to run properly, the nested expression does the trick. Sweet!
Any developers reading this thread, shouldn't this be a little easier? Would be nice to have a cleaner way to code this.
Jordan
Re: JSL: Launch platform dialog for user input, then modify reportPlaying around with this some more, it looks like the nested expressions aren't even necessary. This works too:
Names Default To Here( 1 );
dt = As Table( J( 20, 1, Random Uniform() ) );
dt << distribution(
action(
distHandle = Current Report();
For( i = 1, i <= 3, i++,
distHandle[Outline Box( 1 )] << append( Text Box( "Yay!" ) )
);
)
);
I retract my earlier comment asking for a better way to code this!
What tripped me up is that Action() is not like a modal dialog -- it doesn't halt script execution. Any code following the Distribution call is executed immediately, even before the user clicks "OK". Everything that needs to happen after user input has to be wrapped inside the Action() argument.
Thanks again @brady_brady and @stan_koprowski for showing the way.