Hi!
Manolas Smith wrote: ↑Fri Dec 09, 2022 12:14 pm
MaidStartingTime (the number of days that the maid service will last)
Just a small little general hint, ... I am a fan of (and I know from my own experience) that good-describing-identifiers (Variabel-Names) will do you a favor, ... so I would suggest a Variable-Name like 'MaidServiceDurationDays'.
For the questions, ... for me personally it's always easier to help when I actually see the script you are talking about instead of just describing it, ... I'll try anyway ...
From your post it looks like there is a missing start date, ... so when that maid service starts, you would need something like:
Code: Select all
@NullResponse @SetDate(MaidServiceHasStartedAt,1 second)
I would also add a Flag, I guess that could be useful anyway around other scripts, like the Flag 'MaidServiceIsActive', so the line above added with the flag:
Code: Select all
@NullResponse @SetDate(MaidServiceHasStartedAt,1 second) @SetFlag(MaidServiceIsActive)
---> That will write the date and time into the variable when that command was executed.
The Variable 'MaidServiceHasStartedAt' would look like (in example):
09.12.2022 19:03:17
Now you have a date and time to compare the amount of days with of how long it should last and so on.
Let's say it should last 3 days, maybe can be raised because of your actions, but it has a maximum of 7 days
Now all you have to do is to compare the noted date/time with the given variables, i.e.:
Code: Select all
@NullResponse @Flag(MaidServiceIsActive) @Variable[#DateDifference(MaidServiceHasStartedAt,days)]>=[MaidStartingTime] @Goto(ResetMaidService)
---> Let's say MaidStartingTime was modifed and is now at 20, but you want the maximum of 7 days, then the line above wouldn't jump to the (ResetMaidService) after 7 days, so to catch the maximum you'll need the second line:
Code: Select all
@NullResponse @Flag(MaidServiceIsActive) @Variable[#DateDifference(MaidServiceHasStartedAt,days)]>=[MaidMaximumTime] @Goto(ResetMaidService)
I must say that in the beginning I had some problems understanding the #DateDifference thing myself, to get a feeling of that, you might try these script lines:
Code: Select all
Set date now @SetDate(TheNotedDateAndTime,1 second)
The difference is: #DateDifference(TheNotedDateAndTime,second) seconds
(loop)
Now the difference is: #DateDifference(TheNotedDateAndTime,second) seconds @Goto(loop)
Best greetings and happy scripting,
Markus
(And btw.: Don't forget to share your scripts once they are in shape to be shared!
)