You can generate the dynamic part of the Legend Position and build the required list
Names Default To Here( 1 );
uni_bat = {a, b, c, d};
theList = {9, 10, [-1, -1, -1, -1]};
mat = Shape( Matrix( Index( 1, N Items( uni_bat ) - 1 ) ), N Items( uni_bat ) - 1 ) |/
[-1, -1, -1, -1, -1, -1, -1, -1, -1,-1, -1];
insert into(theList, mat, 2);
show(theList);
and then plug it into the Legend Position message as demonstrated in the below simplified example
Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder(
Show Control Panel( 0 ),
Variables(
X( :height ),
Y( :weight ),
Overlay( :sex )
),
Elements(
Points( X, Y, Legend( 3 ) ),
Smoother( X, Y, Legend( 4 ) )
)
);
theList = {3, 4, [2, 1]};
mat = [4,3];
insert into(theList,mat,2);
eval(parse("Report( gb )[LegendBox( 1 )] << Legend Position( "||char(theList)||" );"));
Jim