4.10 FAQ-369 如何在 Labtalk 脚本中遍历各种对象?
Last Update: 11/27/2024
document命令可用于循环遍历Origin对象。 其中 -e 开关允许用户指定要循环遍历的对象类型,而 -ef 开关则将循环的范围限制于当前文件夹的所有对象。
以下示例将会遍历所有工作簿中的所有工作表(图层)来获取指定的单元格的值。其中该单元格所在位置是某个指定长名称的列中的某一行。
// Loop over all books doc -e W { // Put book name into a string variable - could just use %h book$ = %h; type "Book is: %(book$)"; // loop over all sheets doc -e LW { // Put sheet name into variable sheet$ = layer.name$; type "Sheet is: %(sheet$)"; // (Re)Define a range to point to the column with long name // "system pressure" range r = [%(book$)]%(sheet$)!col(system pressure); // Get row 5 of col "system pressure" of current sheet of // current book double d = r[5]; // check if missing value if( d != 0/0 ) type "system pressure row 5 = $(d)"; } }
Keywords:page, layer, column, row, folder, worksheet, workbook, matrix, 页面,图层,列,行,文件夹,工作表,工作簿,矩阵