Thanks to the example you provided in detail, ALL ISSUES (Q1, Q2) have been resolved.
theList = {9, 10, [-1, -1, -1, -1]}; <BR />mat = Shape( Matrix( Index(<FONT color="#FF0000"> 0,</FONT> N Items( uni_bat ) - 1 ) ), <BR />N Items( uni_bat ) ) |/ [-1, -1, -1, -1, -1, -1, -1, -1];
As above, in the script you gave me, I was able to make the result completely what I wanted by adding 0 in front of N items.
Thank you again Jim for always kind answers!!!
Please be careful COVID19!
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)||" );"));The JSL code you are attempting to modify, can be more easily handled using messages sent to the Legend Box() messages. Below is the entry from the Scripting Index that gives an example of modifying the Legend Position. Using this method, your IF() statement structure will work as you assumed it would in your example.

Go to
Help=>Scripting Index
to access the above display