该帮助的版本不再更新,请参见https://www.jmp.com/support/help/zh-cn/15.2 获取最新的版本.


If you want to receive a message when a data table changes, use the Subscribe message. For example, you might want a message sent to the log when columns are added or deleted.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
delRowsFn = Function( {a, b, rows},
dtname = ( a << Get Name());
Print( dtname );
Print( b );
Print Matrix( rows );
addRowsFn = Function( {a, b, insert},
dtname = ( a << Get Name() );
Print( dtname );
Print( b );
Print( insert );
dt << Subscribe( "Test Delete", onDeleteRows( delRowsFn, 3 ) );
dt << Subscribe( "Test Add", onAddRows( addRowsFn, 3 ) );
Subscribe to Data Table List() subscribes to a list of data tables to be notified when a new data table has been added or closed. The following example shows how to subscribe and unsubscribe:
f2 = Function( {x}, Show( x ) );
Show( Subscribe to Data Table List( "My Data", OnClose( f2 ) ) );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Wait( 2 );
Close( dt );
Show( Unsubscribe to Data Table List( "My Data" ) );
If Subscribe is called with an empty application name, JMP generates a unique name that is returned to the caller. In the following example, appname2 is subscribed to the data table as a client.
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
appname1 = dt << Subscribe( "", On Close( Print( "Closing Data Table" ) ) );
""( "client" ),
Function( {dtab},
Print( dtname );
dt << Unsubscribe( appname1, On Close );
dt << Run Script( "Distribution" )