cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
txnelson
Super User

How to correctly clear a Row State Handler

I have a very simple Row State Handler that makes sure that a given selected row can never be unselected.  The issue is, that I want to turn off that functionality and continue with normal operations.

Here is the simple script that locks down row 15 to always be selected.

 

names default to here(1);

dt=open("$SAMPLE_DATA\big class.jmp");

x=15;

dt << select rows(x);

setrow = function({x},dt<<clear
select();dt<< select rows(x));

rs = dt << Make Row State Handler(setrow(x));

 

So now the question is, how do I remove the Row State Handler, short of closing and reopening the data table?  I can change the rowstate handler to a different function, but I would prefer to just remove the Row State Handler.

 

Does anyone have an answer?

Jim
1 ACCEPTED SOLUTION

Accepted Solutions
cis_pete
Level III

Re: How to correctly clear a Row State Handler

Probably not the correct solution but I assign an empty function to the row state handler:

 

 

empty_function = function({x},{z},
    z = 1;
);

rs = dt << Make Row State Handler(empty_function);

 

Somehow it does not work if the function is completely empty, so I added z=1 as 'dummy code'.

 

Regards

Peter

 

PS: How can you format sample code as 'code' (like you did)? Seems like I am too dumb to understand the forum software.

View solution in original post

6 REPLIES 6
cis_pete
Level III

Re: How to correctly clear a Row State Handler

Probably not the correct solution but I assign an empty function to the row state handler:

 

 

empty_function = function({x},{z},
    z = 1;
);

rs = dt << Make Row State Handler(empty_function);

 

Somehow it does not work if the function is completely empty, so I added z=1 as 'dummy code'.

 

Regards

Peter

 

PS: How can you format sample code as 'code' (like you did)? Seems like I am too dumb to understand the forum software.

pmroz
Super User

Re: How to correctly clear a Row State Handler

I copy/paste JSL code to MS-Word, then copy/paste it from Word to here.  For example:

empty_function = function({x},{z},

    z = 1;

);

rs = dt << Make Row State Handler(empty_function);

cis_pete
Level III

Re: How to correctly clear a Row State Handler

Thanks.

ms
Super User (Alumni) ms
Super User (Alumni)

Re: How to correctly clear a Row State Handler

The below seems to clear the row state handler (but not the current row states):

Clear Globals(rs);

thomasz
Level IV

Re: How to correctly clear a Row State Handler

An old question, but why not just setting rs=0 ?

Re: How to correctly clear a Row State Handler

I think that you only need to assign empty to the variable that previously stored the reference to the handler. You need to use a Wait( 0 ) function call before de-assigning the handler to make sure that all updates are caught up and the script is in sync. (Thanks to Dan Schikore for the tip about Wait.)

 

See this example and examine the Log after it runs. Only the first two row state changes cause output to the Log.

 

Names Default To Here( 1 );

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

// example handler
f = Function( {a}, Show( a ) );

// assign handler
rs = dt << make row state handler( f );

// test handler
dt << Select Rows( 1 );
dt << Select Rows( 5 );

Wait( 0 );

// de-assign handler
rs = Empty();

// test absence of handler
dt << Select Rows( 3 );
dt << Select Rows( 9 );