I think it is better idea to return the new column and then add that outside of the function call
Names Default To Here(1);
dt = Open("\\VMSPFSFSLC001\F28_PLI\SQL\FE SQL\Data\Oxide .CSV");
op_list = List();
add_new_operation = Function({dt, col_name, op, PLmin, PLmax}, {Default Local},
new_col = dt << New Column(col_name,
Character,
"Nominal",
Formula(
If(/*some conditions for the value*/
)
)
);
return(new_col);
);
sticol = add_new_operation(dt, "STI", 201405, 80, 2000);
Insert Into(op_list, sticol);
Show(op_list);
// This should also work
// Insert into(op_list, add_new_operation(dt, "STI", 201405, 80, 2000));
Full example
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
op_list = {};
add_new_operation = Function({dt, col_name}, {Default Local},
new_col = dt << New Column(col_name,
Character,
"Nominal",
Formula(
col_name
)
);
return(new_col);
);
Show(op_list); // op_list = {};
Insert into(op_list, add_new_operation(dt, "name"));
Insert into(op_list, add_new_operation(dt, "age"));
Show(op_list); // op_list = {Column("name 2"), Column("age 2")};
-Jarmo