0
Answered

Show messages time depending

Leandro Augusto 6 days ago • updated by Aleksandr Romanov (CTO) 5 days ago 2

I want to show on panel messages like Good Morning, Good Afternoon and Good Evening depending on time of the day.

I think about to use SetInteval and a function to check how time it is. But I don´t know if it is a good choice.

Can you help me?

GOOD, I'M SATISFIED

Thanks for helping!

Satisfaction mark by Leandro Augusto 5 days ago
Under review

Hello

You can track time changes using the global listener and system time tokens.

https://dev.iridi.com/Systems_API/en#IR.SetGlobalListener

https://dev.iridi.com/Tokens_API/en#Time

Depending on the value of the token, you can show different messages. Example:

IR.AddListener(IR.EVENT_START,0,function()
{

function UpdateMessage()
{
if(IR.GetVariable("System.Time.Hour")>=6 && IR.GetVariable("System.Time.Hour")<12)
IR.Log("Goog Morning!")
if(IR.GetVariable("System.Time.Hour")>=12 && IR.GetVariable("System.Time.Hour")<18)
IR.Log("Good Afternoon!")
if(IR.GetVariable("System.Time.Hour")>=18 && IR.GetVariable("System.Time.Hour")<0)
IR.Log("Good Evening!")
if(IR.GetVariable("System.Time.Hour")>=0 && IR.GetVariable("System.Time.Hour")<6)
IR.Log("Goog Night!")

}

UpdateMessage();

IR.SetGlobalListener(IR.EVENT_GLOBAL_TAG_CHANGE, UpdateMessage);
IR.SubscribeTagChange("System.Time.Hour");
});