Page 1 of 1

Exit loop after 20 min

Posted: 15 Dec 2022, 13:46
by Cincin
Hi,

I have a procedure with a loop and would like to exit the loop after 20 min. The "Time condition" action would be perfect for this task, but I can't figure out, how to put the correct exit time (system time + 20 min) into the actions parameters.

My idea is:

1. Read the current system time, add 20 min and save the result in a variable "ExitTime" as a string.
2. Start the procedure with the loop.
3. The "Time condition" checks if ExitTime is reached, if not, the procedure is restarted - otherwise the macro continues with the next action. Something like that:

Code: Select all

<action name="ActionTimeCondition">
    <exception id="0" action="0" line=""/>
    <exception id="1" action="0" line=""/>
    <exception id="2" action="1" line=""/>
    <parameter name="date">
        <subParameter name="value" code="1">ExitTime</subParameter>
    </parameter>
    <parameter name="ifAfter">
        <subParameter name="action" code="0">call_procedure</subParameter>
        <subParameter name="line" code="0">TimeLoop</subParameter>
    </parameter>
    <parameter name="ifBefore">
        <subParameter name="action" code="0">do_nothing</subParameter>
        <subParameter name="line" code="0"></subParameter>
    </parameter>
    <parameter name="ifNow">
        <subParameter name="action" code="0">do_nothing</subParameter>
        <subParameter name="line" code="0"></subParameter>
    </parameter>
</action>
My problem is, that I don't know how to create this "ExitTime" variable. Or is there maybe even a better way to solve this?

In general, I would be interested to know how to calculate time. I have another macro where you enter a quantity, but internally this should then be converted into processing time. If you enter 1000, I calculate the duration with 1000 x 1,5s = 1500 sec = 25 min. So for example the loop should run for 25 min, or at run time there should be a pause for 25 min. Or when the time (system time + 25 min) is reached, a certain procedure should be executed.

Re: Exit loop after 20 min

Posted: 15 Dec 2022, 20:04
by francois
Hi,

You have an example in the french forum :
viewtopic.php?p=25320#p25320

Re: Exit loop after 20 min

Posted: 18 Dec 2022, 12:40
by Cincin
Thank you very much. Your example helped alot. The rest I could figure out myself with the help of this online tutorials:

https://www.w3schools.com/js/js_dates.asp