Jump to content

Define WAIT time as a variable


Recommended Posts

Posted

As I understand the Polisy programming capability, a WAIT time can be defined as a value immediately following the WAIT function in a program line.  I would like to define the WAIT time by a user defined variable and have this variable be processed as part of the overall program execution to achieve a user defined time delay.

Is there any way in which this capability can be achieved?

Posted

The Repeat statement, with the While option, allows you to repeat a command (such as a Wait) the number of times that the variable referenced in the While condition is true. 

Posted

I don't know of any way to do that directly.  

The best I can think of is to use "repeat while" as guy mentioned and then set a program to count.

Something like

ID - [ID 0058][Parent 0093]

If
   - No Conditions - (To add one, press 'Schedule' or 'Condition')
 
Then
       (optional line here to disable triggering program)
        Repeat While $countervar < $chosenvartowait
           $countervar += 1
           Wait  1 second
        Repeat 1 times
           Set whatever you want to happen
           $countervar  = 0
           (optional line here to re-enable triggering program)
 
Else
   - No Actions - (To add one, press 'Action')
 

You just have to make sure whatever you put in your "if" section doesn't re-trigger and cancel the wait midstream leaving the countervar at some counted up value.  You may make this two programs and have this program be disabled and have the first program run this program and set this program to disable then re-enable the first program.

Posted (edited)
On 5/13/2025 at 3:27 PM, CMortimer said:

As I understand the Polisy programming capability, a WAIT time can be defined as a value immediately following the WAIT function in a program line.  I would like to define the WAIT time by a user defined variable and have this variable be processed as part of the overall program execution to achieve a user defined time delay.

Is there any way in which this capability can be achieved?

It only takes a few lines of code to create a variable timer that self starts and self runs. This one has been tested for years.

https://forum.universal-devices.com/topic/45088-wait-variable-minutes/#findComment-394015

Edited by larryllix
Posted (edited)

Might do it this way depending on your needs.  This mod to the program above causes the counter to trigger on you setting the variable to whatever time period you want to wait.  Shouldn't need two programs (depending on how you are setting the variable for countdown) as this program won't re-trigger unless you change the value of that variable mid count, in which case I assume you would want it to start over.

In summary, the below program runs as soon as you set the variable $chosenvartowait to any positive number.  It will then count every second until it reaches that number.   Obviously, change your wait time to minutes or hours or whatever if you want to count those instead.  

Also note, I moved the wait 1 second line up above the add 1 to the variable line.  I think it would terminate 1 second too soon otherwise.  And I moved the reset of the counter variable to the first line ensuring if you change the variable mid count it will reset it.  

ID - [ID 0058][Parent 0093]

If
       If $chosenvartowait > 0  (need to setup this variable as a state variable)   

Then
       $countervar  = 0 
       Repeat While $countervar < $chosenvartowait
           Wait  1 second
           $countervar += 1
        Repeat 1 times
           Set whatever you want to happen
          
           
 
Else
   - No Actions - (To add one, press 'Action')
 

 

Edited by apostolakisl

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...