Jump to content
View in the app

A better way to browse. Learn more.

Universal Devices Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Define WAIT time as a variable

Featured Replies

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?

Solved by apostolakisl

Go to solution

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. 

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.

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

  • Solution

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

Guest
This topic is now closed to further replies.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.