我需要每天更新此表(如下所示)

我會每天更新新的產品ID和recipe_A&recipe_B。
然後我需要排序 recipe_A和recipe_B到另外兩個列(sort_A&sort_B)。
所以我複制 recipe_A&recipe_B to sort_A&sort_B,並運行此腳本(如下所示)
這樣,我可以重新編碼 sort_A&sort_B。
Current Data Table() << Begin Data Update;
For Each Row( :sort_A = Match( :sort_A, "ZXC", "worse", "QWE", "better", "ASD", "good", :sort_A ) );
Current Data Table() << End Data Update;
Current Data Table() << Begin Data Update;
For Each Row( :sort_B = Match( :sort_B, "R123", "rrr", "H123", "hhh", "G123", "ggg", :sort_B ) );
Current Data Table() << End Data Update;
我的問題是:
如何創建腳本以自動將recipe_A和recipe_B複製到sort_A&sort_B?
(如果缺少sort_A和sort_B數據,則自動複製)?
下面是代碼的返工,以檢查sort_A或sort_B列是否存在,如果不存在,則創建它並填充它。 如果它確實存在,那麼重新填充它。 由於sort_A和sort_B的結果基於recipe_A和recipe_B的值,因此無需將值複製到sort_A和sort_B,然後更改每個值中的值。 只需使用recipe_A和recipe_B中的值來設置sort_A和sort_B中的值就容易多了。
Names Default To Here( 1 );
dt = Current Data Table();
// Get a list of the current columns in the data table
ColList = dt << get column names( string );
// See if a column named "sort_A" does not exist
If( N Rows( Loc( ColList, "sort_A" ) ) == 0,
// If it does not exist, create the new column and use a formula to populate the values based upon the recipe_A values
dt << New Column( "sort_A", character, formula( Match( :recipe_A, "ZXC", "worse", "QWE", "better", "ASD", "good", :recipe_A ) ) );
// Remove the formula which will leave the results
dt:sort_A << delete formula;
,
// If the column already exists, then loop through the data table creating new values for sort_A based upon the recipe_A values
For Each Row( :sort_A = Match( :recipe_A, "ZXC", "worse", "QWE", "better", "ASD", "good", :recipe_A ) )
);
// See if a column named "sort_B" does not exist
If( N Rows( Loc( ColList, "sort_B" ) ) == 0,
// If it does not exist, create the new column and use a formula to populate the values based upon the recipe_B values
dt << New Column( "sort_B", character, formula( Match( :recipe_B, "R123", "rrr", "H123", "hhh", "G123", "ggg", :recipe_B ) ) );
dt:sort_B << delete formula;
,
// If the column already exists, then loop through the data table creating new values for sort_B based upon the recipe_B values
For Each Row( :sort_B = Match( :recipe_B, "R123", "rrr", "H123", "hhh", "G123", "ggg", :recipe_B ) )
);