The following sections describe how to add and delete display boxes from a report using Append(), Prepend(), Delete(), and Sib Append().
Use the Append message to add a display box to the bottom of an existing display. In the script, construct a single, empty box, then append boxes to it for each variable in the analysis. You can also use the Append message to modify an existing display with custom information or organization.
The following code example assumes that there is a list of effect names in the variable effectsList, and that each one corresponds to a column in a matrix varprop. In other words, effectsList[1] is the label for varprop[0,1]; effectsList[2] is the label for varprop[0,2]; and so on.
varprop = [0 1 2, 3 4 5, 6 7 8];
effectsList = {"one", "two", "three"};
First, an empty Outline Box containing an H List Box is created. The interior empty container is given the name hb:
win = New Window( "H List Box Example",
Outline Box( "Variance Proportions", hb = H List Box() )
);
Then, a for loop steps through the effectsList and adds a Number Col Box for each element of effectsList:
For( i = 1, i <= N Items( effectsList ), i++,
Eval(
Substitute(
Expr(
hb << Append(
Number Col Box( effectslist[i], varprop[0, i] )
)
),
Expr( i ), i
)
)
);
Sib Append() is similar to Append() but makes the display box a sibling of the last child display box. For an example that compares Append() to Sib Append(), see Append (Left) and Sib Append (Right).
The Prepend message works just like Append but adds the item at the beginning of the display box rather than at the end. If the display box is one of several that do not allow appending, then Prepend delegates the command to a child display box that can accept the command. It is fine to apply it to the top of the tree.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = dt << Bivariate( Y( height ), X( weight ), Fit Line );
(biv << Report)(Outline Box( 1 )) << Prepend(
// select the first outline box in the biv report layer
// send the Prepend message to the first outline box
Button Box( "Click here for curve", biv << Fit Polynomial( 2 ) )
// prepend a button box that fits a quadratic curve
);
Click the Click here for curve button to add a quadratic curve to the graph.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = dt << Bivariate( Y( height ), X( weight ), Fit Line );
biv << Report << Prepend( // send the prepend message to the report
Button Box( "Click here for curve", biv << Fit Polynomial( 2 ) )
// prepends the button box to the top of the report
);
The Delete message removes the specified display box and all its children from the report. This is useful with the Append and Prepend messages for building completely dynamic displays. In the example below, a text box is replaced with another text box. In this case, the script could have used Set Text, but many display boxes cannot change their content.
win = New Window( "X",
list = V List Box(
t1 = Text Box( "t1" ),
t2 = Text Box( "t2" )
)
);
t1 << Delete;
list << Append( t1 = Text Box( "t1new" ) );
Note: Avoid deleting display boxes from a JMP platform. Send the Hide( 1 ) message or the Visibility( "Hidden" ) message to the display box that you want to hide.
You can use the Sib Append message to add a display box immediately after an existing display box. Appending a Sibling Text Box shows two picture box trees. Picture Box( 1 ) holds the Bivariate scatterplot. Picture Box( 2 ) holds the Fit Mean menu, determined by seeing the green line and the Fit Mean text box.
Suppose you wanted to insert a text box in between these two boxes. We want to append a sibling to Picture Box( 1 ), so we send it the Sib Append message:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = dt << Bivariate(
Y( :weight ),
X( :height ),
Fit Mean( {Line Color( {57, 177, 67} )} )
);
Report( biv )[Picture Box( 1 )] << Sib Append( Text Box( "Hello There" ) );
/* the report function takes the biv object and returns a report object.
append the text box immediately after the first picture box */
Note: In Appending a Sibling Text Box, the appended sibling text box appears below the first picture box in the Show Tree Structure View window. In the classic Show Tree Structure View window, siblings appeared next to each other in the display tree. See View the Display Tree for details.
Append (Left) and Sib Append (Right) shows the difference between and Append() and Sib Append(). Append() makes the display box a child of the parent display box. Sib Append() makes the display box a sibling of the last display box.
Note: If the parent display box is not a V List Box(), Sib Append() wraps that display box in V List Box().