0
Answered
Countdown Timer
Khurram Masud 9 years ago
in iRidium Script
•
updated by Ekaterina (head of support) 9 years ago •
1
Timer.irpz
Hello,
I am trying to insert a countdown timer in the application. When i press the button, the countdown starts from 60 Secs to 0 Secs.
i have tried it using the string 'GetState.Text = 60' then 'GetState.Text = 59' and so on... but i need to put delay of 1 sec in between, how is it possible?
Also, Is there any other way of doing this?
Please reply
Thanks,
Khurram
Hello,
I am trying to insert a countdown timer in the application. When i press the button, the countdown starts from 60 Secs to 0 Secs.
i have tried it using the string 'GetState.Text = 60' then 'GetState.Text = 59' and so on... but i need to put delay of 1 sec in between, how is it possible?
Also, Is there any other way of doing this?
Please reply
Thanks,
Khurram
Answer
0
Answer
Answered
Ekaterina (head of support) 9 years ago
Answer
Answered
var counter; function count () { // stop interval if it has been started before IR.ClearInterval(counter); //start value var time = IR.GetItem("Page 1").GetItem("Item 1").GetState(0).Text = 60; function count () { //if time > 0 then subtract 1 and send to text field if (time > 0) { IR.GetItem("Page 1").GetItem("Item 1").GetState(0).Text = --time; } else { // stop subtracting if time <=0 IR.ClearInterval(counter); }; } // start function count every 1000 ms (1 s) counter = IR.SetInterval(1000, count); }you can start the timer with Script Call command:
Customer support service by UserEcho