Page 1 of 1

Re: MacroLoop Quirk ??

PostPosted: Fri Mar 02, 2018 2:20 pm
by cncdrive
No, there is no such bug in macroloops. The macro loop code is compiled and executed as it is typed. It is directly compiled by the .NET compiler, so it is not possible that the macro compiler creates another thread when you not coding to create another thread.

Re: MacroLoop Quirk ??

PostPosted: Fri Mar 02, 2018 2:36 pm
by cncdrive
I modified the macro a bit to be able to test it here now.

Code: Select all
exec.Setoutpin(2,10);
exec.Clroutpin(2,10);

if (!AS3.GetLED(10))
{
string Num ="2";
exec.AddStatusmessage("one");

while(!AS3.GetLED(10))
{
  // Wait for Button Release
  Thread.Sleep(100);
  exec.AddStatusmessage("two");

}

}


It checks the port#1 pin#10 LED for the IF and the WHILE loop.
So, when I'm triggering the input it writes "one" and then it writes "two" multiple times until I release the input.
Then when I'm triggering the input again it does the same again.
So, the macro works fine as it should.

Re: MacroLoop Quirk ??

PostPosted: Fri Mar 02, 2018 3:31 pm
by cncdrive
And what does that button do?
You checking a LED not a button, so the question is how does the button trigger the LED? Maybe the problem is in that code.

Re: MacroLoop Quirk ??

PostPosted: Fri Mar 02, 2018 3:34 pm
by cncdrive
And if the "one" and "two"s are repeating does not mean that the loop is duplicated, just that the loop went to the end and then started from the beginning again,
so that means the the LED you reading changed states, flickered etc.

Re: MacroLoop Quirk ??

PostPosted: Fri Mar 02, 2018 6:13 pm
by cncdrive
OK, I thought it is a button on the screen, a virtual button which somehow set something to set that LED.
Now I see that you physically triggering the port#4 pin#2 which is LED 104. and checking that LED in the macro.
So, I've changed the macro which I already modified a bit as I posted to look for LED 104. instead of LED 10. and then I triggered the port#4 pin#2 kept it on and then released it finally.
And it works fine at me, it works the same, it writes "one" when the pin is triggered and write "two"s until I release the pin. And when I do it again then it again does the same with "one" and then "two"s.

I think it should be something with how you triggering the input. It could be a prell on the button or something which releases the pin and so you see lots of "one"s because the loop restarts when the pin is released for even a short time.

Re: MacroLoop Quirk ??

PostPosted: Fri Mar 02, 2018 6:15 pm
by cncdrive
Terry, and one more idea to check is if you running this macro in one loop only.
I know it is a silly idea, but if the same macro runs in multiply instances could also cause strange results.
I mean to check if the macro is enabled only in one macroloop slot. :)