## Using Variables in Dispatch

Community Trekker

Joined:

Feb 6, 2012

Hello,

I am trying to manipulate the axes of a graph with Dispatch. The following code works well:

SendToReport(

Dispatch(

{},

"Precursor",

ScaleBox,

{Min( 3395001600 ), Max( 3413404800 ), Interval( "Day" ), Inc( 5 ), Minor Ticks( 0 ), Rotated Labels( 1 )}

),

However, I need to script quite a number of graphs, so I would like to wrap them into a loop, which also works in principle (the graphs are created and the data displayed). What does not work, is the manipulation of the axes. The code I use is:

date_list= list("Precursor", "BL", "TCO");

i=1;

SendToReport(

Dispatch(

{},

date_list,

ScaleBox,

{Min( 3395001600 ), Max( 3413404800 ), Interval( "Day" ), Inc( 5 ), Minor Ticks( 0 ), Rotated Labels( 1 )}

),

This does not work. The message I get in the log is

Cannot find ScaleBox Subscript

Does JMP9 accept variables in Dispatch?

Any help is appreciated.

Cheers

Arno

Super User

Joined:

Jun 23, 2011

Try to store the code for the graph as an expression and then use Substitute() before evaluating the expression. I don't know why dispatch can't handle a variable. There are other situations I've run into in JSL where arguments just have to be quoted strings and I have still not figured out a way to tell which functions/messages that refuse to take a variable. Perhaps there is no logic, just that some jsl-functions are still in beta-version and may accept variables in future versions of JMP.

In any case, the eval(substitute)-method is a workaround that solves many of these situations.

An example:

Open( "\$ENGLISH_SAMPLE_DATA/Big Class.jmp" );

somelist = {"1", "2"};

i = 1;

biv = Expr(

Bivariate(

Y( :weight ),

X( :height ),

SendToReport(

Dispatch(

{},

somelist[i],

ScaleBox,

{Min( 0 ), Max( 100 ), Inc( 5 ), Minor Ticks( 1 )}

)

)

)

);

Eval( Substitute( Name Expr( biv ), Expr( somelist[i] ), somelist[i] ) );