Page 1 of 1

Error Rules with %sysmonth%

Posted: 30 Aug 2021, 08:12
by Heracles44
Hello,

Sorry for my bad English. I’m French.

Yesterday, this rule do else (50), so false, but now, it’s 08:

on ledm1 do
if %sysmonth_0% > 03 or %sysmonth_0% < 10
asyncevent,pwm12=80
else
asyncevent,pwm12=50
endif
endon

I changer that. This morning, the new rules do right (80). But, month is 08. It’s not <= 03 or not >= 10. So this new rules is normally false.

on ledm1 do
if %sysmonth_0% <= 03 or %sysmonth_0% >= 10
asyncevent,pwm12=80
else
asyncevent,pwm12=50
endif
endon

I tried with %sysmonth% too and same error.

Where is the problem please?

Re: Error Rules with %sysmonth%

Posted: 30 Aug 2021, 21:41
by TD-er
Please do not use the variable with a leading 0

A value starting with a 0 (not "0x123" as in a HEX number) is often considered in octal representation.
So values 0..7 work just like in decimal or hexadecimal notation, but at "8" things start to work different.

So better use %sysmonth% instead of the version which adds a leading zero.

Re: Error Rules with %sysmonth%

Posted: 30 Aug 2021, 21:55
by Heracles44
Ok but I tried too with %sysmonth% and same problem.

Re: Error Rules with %sysmonth%

Posted: 30 Aug 2021, 22:06
by TD-er
Your numbers also have a leading 0

Re: Error Rules with %sysmonth%

Posted: 30 Aug 2021, 22:37
by Heracles44
This don’t work too:

if %sysmonth% > 3 or %sysmonth% < 10

Re: Error Rules with %sysmonth%

Posted: 30 Aug 2021, 22:47
by TD-er
OK, I don't really get your problem then...

Just re-read your initial post and I wonder what you try to do with this line in your rules:

Code: Select all

if %sysmonth_0% > 03 or %sysmonth_0% < 10
Just assuming, it is not having issues with any leading zeroes.
What is stated here can be simplified to this:

Code: Select all

true
X > 3 or x < 10 is always true.

If you want to match the months April ... September, then you should write:

Code: Select all

if %sysmonth% > 3 and %sysmonth% < 10
It needs an AND and not an OR.

Re: Error Rules with %sysmonth%

Posted: 30 Aug 2021, 23:07
by Heracles44
I’ve right. It’s me.

X > 3 or X < 10 it’s all ways true...

I’m stupid lol

Re: Error Rules with %sysmonth%

Posted: 31 Aug 2021, 20:21
by TD-er
Don't be too hard on yourself.... Has happened to any programmer, for sure and not just once ;)
So consider yourself a programmer ;) (and "just" human)