MacroLoops and error conditions

If you have a question about the software please ask it here.

Re: MacroLoops and error conditions

Postby dezsoe » Wed Oct 17, 2018 6:34 pm

What do you mean by internal error? If it is an error like in the sample below then here you are:

Code: Select all
try
{
  // All your code here
  int j = 10 / i--;
}
catch (Exception ex)
{
  // Handle the error
  exec.AddStatusmessage("Error! " + ex.Message);
  exec.Callbutton(130);
  loop = false;
}

#Events

int i = 50;

(Start as a macroloop, it will divide by zero after 50*20 ms. Displays message, presses stop, stops macroloop.)

Edit: You can also turn on a flashing LED to show the error condition.
dezsoe
 
Posts: 594
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary

Re: MacroLoops and error conditions

Postby dezsoe » Wed Oct 17, 2018 9:23 pm

That's impossible. I tried a few times before I posted. Video.

The only thing is, that the variable loop is read-only before 1.2104, so the macroloop cannot stop itself by setting loop=false. I made a little change to use an own loop variable:

Code: Select all
if (myloop)
{
  try
  {
    // All your code here
    AS3.Setfield((double)i, 21005); // This field is to see if the loop is running
    int j = 10 / i--;
  }
  catch (Exception ex)
  {
    // Handle the error
    exec.AddStatusmessage("Error! " + ex.Message);
    exec.Callbutton(130);
    myloop = false;
  }
}

#Events

int i = 50;
bool myloop = true;

This video is with the modified code and 1.2049. A field (21005) is placed below the MDI DRO to show if the loop is running.
dezsoe
 
Posts: 594
Joined: Sun Mar 12, 2017 4:41 pm
Location: Csörög, Hungary


Return to Ask a question from support here

Who is online

Users browsing this forum: No registered users and 1 guest