1

I am writing testcases in CAPL and want to activate each test case by using "Button" from Panel Designer. The problem is that whenever I pressed the Button, it reacted as if it were pressed twice.

I just simply add a code like this to make that problem visible. (The system variable of "@sysvar::Test_Cases::TC1" is linked to the Button in the Panel Editor)

on sysvar sysvar::Test_Cases::TC1  
{
    putValueToControl("Window","CAPL Output View",@sysvar::Test_Cases::TC1);
}

I expect to see only --> Value of @sysvar::Test_Cases::TC1 =1

But the output is like this:

Value of @sysvar::Test_Cases::TC1 =1 Value of @sysvar::Test_Cases::TC1 =0

Eth
  • 11
  • 1
  • 3

1 Answers1

1

on sysvar X{...} event procedure reacts to value change of X.So in case of button press (0->1) value will be set to one then on button release (1->0) value will be set to zero, so you change the value of X twice. This is why you are getting trigger twice.

To react only once on such button press event, and get notification only once, please use the keyword this and condition statement.

on sysvar sysvar::Test_Cases::TC1  
{
    if (this==1) /* Following block is called only once, on button press 0->1 */
    {
     putValueToControl("Window","CAPL Output View",@sysvar::Test_Cases::TC1);
    }
}
YesIO
  • 125
  • 7
  • Thanks for the Tip. It is correct, with this code you can prevent it. But the same thing happens not only to buttons also switches and I saw some videos on youtube, when they make the same usage, the switch stays stable. I do not know, maybe there is something wrong in my testing environment. – Eth Oct 15 '19 at 14:30
  • In case if you are using switch control, make sure that property 'Button Behavior' = False, then the switch shall stay stable. Then the value will not flicker from between 0 and 1 and 0 again on every click. – YesIO Oct 16 '19 at 08:11
  • Hi, sorry for my late response, this issue became hot for me nowadays. As you suggested, when I set Button Behavior' to False, this time there is no response from the Switch. It became like inactive element in the panel... – Eth Jan 29 '20 at 13:54
  • Element is inactive because you haven't attached any variable .Make sure that your sysvar is attached to button.Check access options of your sysvar,(read/write only) and "Event on Value Assignment" in System Variables configuration. – YesIO Jan 30 '20 at 09:56
  • Hey YesIO, I actually solved the problem, yes you are right, button behaivor should be set to False, but it is not enough. Also Mouse Activation Type should be set to "Left", I do not know why.. I could not find a satisfactory answer... – Eth Feb 03 '20 at 12:05