0
Answered

Show messages time depending

Leandro Augusto 2 months ago updated by Tatiana Kiselyova (expert) 3 weeks ago 4

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 2 months ago
+1
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");
});

Sorry,

But it only works on project starting? If project is opened on panel, message doesn´t update automatically.

Hello.
The script will be triggered when the application starts, and during its operation