Dear JMP Users, this is a simplification of a problem I am currently encountering in a script of mine:
I am trying to encode the creation of a Graph Box inside of a function (here 'Test'), so that I can later loop over this process easily.
However, this code snippet doesn't work because the variables inside of the 'If' (showHorLines, numReferenceLines) don't seem to get evaluated properly, if at all. This is the case even though the other variables I am using in the arguments of the function (width, height) work as intended, which led me to the conclusion that it's the fault of the 'If' inside of the Graph Box.
Clear Globals();
Names Default To Here( 1 );
Test = Function({width, height, showHorLines, numReferenceLines}, {Default Local},
gb = GraphBox(
FrameSize(width, height),
XScale(0, width),
YScale(0, height),
XName("split"),
YName("color"),
//[] Generate grey horizontal lines
If(showHorLines == 1,
PenColor(65);
For(h = 0, h <= numReferenceLines, h++,
HLine(h*height/numReferenceLines)
);
PenColor(0),
);
);
win = NewWindow("new window", gb);
);
Test(200, 200, 1, 10);
Is there a way to resolve this issue, without changing the Graph Box into some other object?
If possible, it would be also nice for this to stay a function because I also once tried a similar approach but with Eval, EvalExpr and Expr which also didn't work and let to a similar fate.
Best Regards