This expanded script should show you how to proceed. It allows the user to make two selections in the same dialog box.
Names Default To Here( 1 );
dt = Current Data Table();
dialog = New Window( "Select Columns", << Modal,
Panel Box( "Column Selection",
Lineup Box( N Col( 2 ),
Text Box( "Select column for munging" ),
m col list = Col List Box( All ),
Text Box( "Select columns for distribution" ),
y col list = Col List Box( All )
)
),
H List Box(
Button Box( "OK",
m col = m col list << Get Selected;
y col = y col list << Get Selected;
),
Button Box( "Cancel" )
)
);
If( dialog["Button"] == -1,
Throw( "User cancelled" )
);
Show( m col, y col );
dt << Select Duplicate Rows( Match( :SerialNumber ) );
xx = dt << Get Selected Rows;
If( N Rows( xx ) > 0,
dt << Delete Dows
);
dt << New Column( "Date Code", Numeric, Continuous, Formula( Munger( :Name( "Serial Number" ), 4, 3 ) ) )
<< New Column( "Vendor", Numeric, Continuous, Formula( Munger( :Name( "Serial Number" ), 1, 3 ) ) )
<< New Column( “Config”, Numeric, Continuous, Formula( Munger( :Name( "Serial Number" ), 12, 5 ) ) );
If( N Items( y col ) > 0,
y expr = Expr( Y() );
For( i = 1, i <= N Items( y col ), i++,
Insert Into( y expr, Column( y col[i] ) )
);
Eval( Substitute( Expr( dt << Distribution( yyy ) ), Expr( yyy ), Name Expr( y expr ) ) );
);
I see no reason in the example that you provided for the column name to change to "batter serial number."