Hello Jono,
As far as I understand your task, you need to perform your code only if the wItemCount==0 condition is true. So, if this condition becomes false after any code line is performed, you want to exit the current test. In this case, the only solution I can suggest is to always check this condition where it is possible. That is, before every code line, add code that will check whether the wItemCount property is still equal to 0.
Since the solution looks quite clumsy, I suggest that you simplify it in the following way.
- Enclose the condition statement in a separate validation function.
- Within the validation function, throw an exception if the condition is not met.
- In the test function (renamed to Test3_inner for the description purposes), call the validation function before every code line.
- Enclose the call of the Test3_inner test function into the try...catch statement:
The following code snippet illustrates the suggestion:
function Test3()
{
try {
Test3_inner();
}
catch(e) {
if (e.number == 1000) {
return false;
}
throw e;
}
return true;
}
function validateListCount()
{
if (0 != Aliases["Nano_UI"]["NanoFrame"]["MainPanel"]["ModulePanel"]["AlarmsTabs"]["AlarmsTabControl"]["Alarms_ActiveAlarmsTab"]["ActiveAlarmsPage"]["ActiveAlarmsSplitContainer"]["AlarmsListSplitterPanel"]["ActiveAlarmsList"]["wItemCount"]) {
throw new Error(1000, "There are some items in the list");
}
}
function Test3_inner()
{
validateListCount();
Aliases["Nano_UI"]["NanoFrame"]["MainPanel"]["NavigationToolbar"]["JobsButton"]["JobsButton_Button"]["ClickButton"]();
validateListCount();
Aliases["Nano_UI"]["NanoFrame"]["MainPanel"]["ModulePanel"]["JobsTabs"]["JobsTabControl"]["ClickTab"]("Job Editor");
validateListCount();
...
// and so on
}