J'ai un nombre arbitraire de colonnes qui définissent les entrées d'un processus, et un tas d'autres colonnes qui sont les sorties, et pour chaque ensemble d'entrées, il y a un tas de lignes de sortie qui sont calées sur le temps.
Est-il possible avec .jsl de créer une nouvelle colonne "setid" qui commence par "1" dans la ligne 1, puis prend les colonnes sélectionnées par l'utilisateur (1 ou plus) et chaque fois que l'une des valeurs de l'une de ces colonnes change, elle incrémente la valeur dans la colonne setid -- sinon le setid reste le même.Nous pouvons supposer que les lignes sont triées raisonnablement par ensemble.
Voici un petit exemple avec lequel vous pouvez commencer.J'ai déterré un vieux code que j'avais fait il y a de nombreuses années et je l'ai modifié.Il apparaît d'abord une boîte de dialogue

Et après avoir sélectionné les colonnes, vous cliquez sur OK et cela crée la nouvelle colonne.
Si vous n'avez pas lu le Guide de création de scripts... vous devriez le faire maintenant.Afin de développer ce script simple, vous devrez comprendre JSL et ce que vous pouvez en faire.Voici le scénario
Clear Symbols();
Names Default To Here( 1 );
dt = Current Data Table();
allcolumnslist = dt << get column names( "string" );
nw = New Window( "Generate SETID Column",
Border Box( Left( 3 ), top( 2 ),
V List Box(
Text Box( "Create a SETID Column" ),
H List Box(
V List Box(
// Generate the master display box for the columns in the data table
Panel Box( "Select Columns",
colListData = Col List Box( width( 180 ), nLines( Min( N Cols( dt ), 15 ) ) ),
colListData << append( dt << get column names( "string" ) ),
// At startup, sselect the columns in the selection box for
// the columns that are selected in the data table
For( II = 1, II <= N Items( All Columns list ), II++,
If( Column( ii ) << get selected == 1,
colListData << set selected( II )
)
);
)
),
// Setup the selection buttons and the selection boxes
Panel Box( "Selected Columns to Create SETID from",
Lineup Box( N Col( 2 ), Spacing( 3 ),
Button Box( "Add Column(s)", colListY << Append( colListData << GetSelected ) ),
colListY = Col List Box( width( 180 ), nLines( 10 ), min col( 1 ), max col( 0 ) ),
)
),
// Setup the action buttons that control the window processing
V List Box(
Panel Box( "Action",
Lineup Box( N Col( 1 ),
Button Box( "OK",
// Check to see if the required data has been input
If( N Items( colListY << GetItems ) == 0,
Dialog( "No Y Columns Specified", Button( "OK" ) ),
// Process the Y Columns
thecols = {};
thecols = colListY << GetItems;
nw << close window;
runit();
)
),
Button Box( "Cancel", Stop() ),
Text Box( " " ),
Button Box( "Remove", colListY << RemoveSelected ),
Button Box( "Help", notImplemented )
)
)
),
)
)
)
);
// Here is the function that calculates the new column.
runit = Function( {},
If( Try( dt:SetID << get name, "" ) != "",
dt << delete columns( {"SetID"} )
);
dt << New Column( "SetID", numeric );
// Set the value for row 1
mySetID = 1;
dt:SetID[1] = mySetID;
// Loop across the remaining rows, checking for a change from the previous row
For( i = 2, i <= N Rows( dt ), i++,
thesame = "Yes";
For( k = 1, k <= N Items( thecols ), k++,
If( Column( dt, thecols[k] )[i] != Column( dt, thecols[k] )[i - 1],
thesame = "No"
)
);
// If a change is found, increase the counter
If( thesame == "No",
mySetID
++);
// Set the value of the new column
dt:SetID[i] = mySetID;
);
);