CMortimer Posted Tuesday at 07:27 PM Posted Tuesday at 07:27 PM 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? Quote
Guy Lavoie Posted Tuesday at 07:49 PM Posted Tuesday at 07:49 PM 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. Quote
apostolakisl Posted Wednesday at 01:12 PM Posted Wednesday at 01:12 PM 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. Quote
larryllix Posted Wednesday at 05:50 PM Posted Wednesday at 05:50 PM (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 Thursday at 09:51 PM by larryllix Quote
apostolakisl Posted Wednesday at 07:29 PM Posted Wednesday at 07:29 PM (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 Wednesday at 07:32 PM by apostolakisl Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.