For the latest version of JMP Help, visit JMP.com/help.


Scripting Guide > Data Structures > Lists > Send Messages to Lists
Publication date: 04/28/2021

Send Messages to Lists

You can send a single message to a list instead of having to send individual messages. Suppose that you want to create a Bivariate report with a By variable. The script returns a list of the bivariate objects, one for each level of the By variable. Send a single Fit Line message to the list to fit a line to all of the Bivariate reports.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

/* return a list of bivariate objects:

{Bivariate[], Bivariate[], Bivariate[], Bivariate[], Bivariate[],

Bivariate[]}; */

biv = dt << Bivariate( X( dt:weight ), Y( dt:height ), By( dt:age ) );
 
biv << Fit Line; /* send the Fit Line message to
each Bivariate object in the list */

Troubleshooting Messages Sent to a List

Any message that is sent to a list is sent to each object in the list. If the message saves a file, it’s performing the save for each object in the list to the same file. This means that only the last object is actually saved in a file.

Suppose that you have a list of three control charts and you send a message (such as Save Interactive HTML) to the list. The message is sent to each member of the list in turn. First, it saves an HTML page with the first control chart; then it saves a second HTML page with the same name that contains the second control chart; and then it saves a third HTML page with the same name that contains only the third control chart. You end up with a page that contains only the third control chart.

The solution is to send the message to a single container higher up the tree that contains all control charts. To do this, rewrite the following line of code:

obj << Save Interactive HTML( "Control Charts.html" );

Top Parent treats the first object as the single container:

tp = obj[1] << Top Parent();
tp << Save Interactive HTML( "Control Charts.html" );
Want more information? Have questions? Get answers in the JMP User Community (community.jmp.com).