Facility Control

 View Only
  • 1.  Loops within Pause

    Posted 09-10-2019 01:36

    Hi all, I' pretty new to java.

    I was wondering if you can do loops within a pause script... it doesn't seem to repeat once it finds the first instance...
    I want it to display every instance of the letter R in 52 text boxes for 1 second each.
    Thanks!!!
     
    for (i = 1; i < 53; i++)
    {
    var letterval = params.getValue('Letter_' + i, 0);
    if (letterval == 'R')
    {
    params.setValue('Letter_Status', 0, i);
    return 1000;
    }
    }
     


  • 2.  RE: Loops within Pause

    Posted 09-12-2019 13:34

    We allow pauses via ogscript.pause(TIME_IN_MILLISECONDS) but you need to run the loop in a function and send it through asyncExec (we disable pauses that would block the user interface).

    If you want it always running every second, you could also use a timer and just have a variable to keep track of which index you want to show).

    One other note with your code - have you considered using an array instead of individual parameters for each letter - might be a better fit depending on your use.

    function myFunction()
    {
    for (i = 1; i < 53; i++)
    {
    var letterval = params.getValue('Letter_' + i, 0);
    if (letterval == 'R')
    {
    params.setValue('Letter_Status', 0, i);
    ogscript.pause(1000);
    }
    }
    }
    ogscript.asyncExec(myFunction);

    #DashBoard