Page 1 of 1

Help on a simple if-then-else script

PostPosted: Sun Dec 03, 2023 2:00 am
by theneo6dude
Hello,

I (simply) need to send a startup script based on a range of time.

In other words, at startup, if it is between 8:00 and 23:00 Widget would send a "play" (SeqSetState) to Pandoras, if it is between 23:00 and 8:00 Widget would send a "stop" command.
I started to write an “if-then-else” script condition , but will need some help to finalize.

I use the system variables “now” but I’m not sure about the Value B as I just need the time not the date.


if Now >= 2023-11-24 08:00:00.000 AND <= 2023-11-24 23:00:00.000 {
 WDWait(2)
 SeqSetState(1,”Play”)
}
 
Else {
 WDWait(2)
SeqSetState(1,”Stop”)
}


Hope that make sense ,
Thx



Windows 10 64 19045.3208
widget version 6.5.6

Re: Help on a simple if-then-else script

PostPosted: Sun Dec 03, 2023 1:28 pm
by Daniel Kaminski
Hi,

there are a few ways to tackle this

a) since you only need to check between full hours, just convert the hours Part of the now time into a integer.
WD_TimecheckFullHours.zip


b) calculate with Times
WD_Checktimes.zip


Trick in both cases is that you can read out any part of a datevariable and also format it in a way you want it with datevariable.format("..")

Hope this helps
Daniel