JSL ScriptHi All,
I am completely new to JMP and writing JSL scripts and I needed a help in building a logic for a case:
I have a table with one of the column as Status and I would like to count the number of 1's in that. It will start counting when it sees first "1" and continue to count until the last and output the final count at the last occurence of 1. And once it sees "0" in the next row, it should reset the counter again and start looking for "1".

I would be really grateful if you help me with this.
Abhi
Re: JSL ScriptCould do this
Names default to here(1);
m = [0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0];
dt = new table("Test",
<< New Column("Status", <<SET values=""></SET>Re: JSL Scriptnames default to here(1);
// create the table
m = [0,0,0,0,0,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,0,0,0];
dt = new table("Test",
new column("Status", set values(m));
);
// create the empty status column
dt << new column("Output");
// iterate over each row of the table
result = 0; // counter for consecutive 1's
for (i=1,i<=nrows(dt),i++,
// apply the logic the way
// that you would think it
value = dt:Status[i]; // i'th row of Status column table referenced by dt
if (value==0,
dt:Output[i] = 0;
result = 0;
,
result = result + 1;
dt:Output[i] = result;
)
);Re: JSL ScriptThank you for the help. The logic is very simple and straight forward and it helps a lot. Thanks again.