大家好,我對 JSL 還很陌生,所以我有一個小疑問,我有 3 個資料表,每個資料表包含 12 行。因此,我想添加一行程式碼,為我提供類似 table1 的輸出 - num col 將是 1-12,對於 table2 - num col 將是 13-24,對於 table-3,num col 將是 25 -36。你能幫我解決這個問題嗎?先感謝您。
l = 117;
w = 32;
h = 43;
ls = 19.6;
ws = 16.4;
hs = 14.3;
numbers = Function({ls, ws, hs, l, w, layer},
dt = New Table("data" || Char(layer),
Add Rows(0),
New Column("num", Numeric, continuous),
New Column("length", Numeric),
New Column("width", Numeric),
New Column("height", Numeric),
);
For(length = ls / 2, length <= l, length += ls,
For(width = ws / 2, width <= w, width += ws,
height = Round(hs * layer, 1);
num = N Rows(dt);
num++;
dt << Add Rows(1);
:num[N Rows(dt)] = num;
:length[N Rows(dt)] = Round(length, 2);
:width[N Rows(dt)] = Round(width, 2);
:height[N Rows(dt)] = Round(height, 2);
)
);
Return(dt);
);
table1 = numbers(ls, ws, hs, l, w, 1);
table2 = numbers(ls, ws, hs, l, w, 2);
table3 = numbers(ls, ws, hs, l, w, 3);看看 Sequence 函數。
幫助>腳本索引>搜尋序列
……或者,更好的是:
啟動新的工作流程,啟動記錄器
在資料表中,使用公式建立一個新列。
在公式編輯器中輸入 -sequence()
函數參數將出現,輸入 start 為 1,end 為 12
應用公式。
然後關閉工作流程記錄器,中提琴你就有了一個腳本,用於添加帶有數字序列公式的列。