你好,
我有兩個資料表,分別名為 HVAC 和 Events。我想根據 Events 表的開始時間和結束時間來匹配 HVAC 表中的日期/時間,並將 HVAC 表中匹配的行標記為 1。
我有一個可以運行的腳本,但沒有填充“匹配”列,我不太清楚為什麼。
Names Default to Here (1);
Clear Symbols();
// Reference both tables
timeEvents = DataTable("Events");
timeHVAC = DataTable("HVAC");
// Get column references
startCol = timeEvents:Round_when_started;
endCol = timeEvents:Round_when_ended;
timeHVACCol = timeHVAC:Round_date;
matchedCol = timeHVAC:Matched;
Batch Interactive( 1 );
// Loop through timeEvents and tag matches
For(i = 1, i <= N Rows(timeEvents), i++,
startTime = startCol[i];
endTime = endCol[i];
// Loop through HVAC and tag matching rows
For(j = 1, j <= N Rows(timeHVAC), j++,
eventTime = timeHVACCol[j];
If(eventTime >= startTime & eventTime <= endTime,
matchedCol[j] = 1;
);
);
);
Batch Interactive( 0 );
// Notify user
New Window("Script Completed",
Text Box("Lucy, I'm home!")
);