Error Rules with %sysmonth%

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Heracles44
New user
Posts: 4
Joined: 30 Aug 2021, 08:05

Error Rules with %sysmonth%

#1 Post by Heracles44 » 30 Aug 2021, 08:12

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?

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Error Rules with %sysmonth%

#2 Post by TD-er » 30 Aug 2021, 21:41

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.

Heracles44
New user
Posts: 4
Joined: 30 Aug 2021, 08:05

Re: Error Rules with %sysmonth%

#3 Post by Heracles44 » 30 Aug 2021, 21:55

Ok but I tried too with %sysmonth% and same problem.

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Error Rules with %sysmonth%

#4 Post by TD-er » 30 Aug 2021, 22:06

Your numbers also have a leading 0

Heracles44
New user
Posts: 4
Joined: 30 Aug 2021, 08:05

Re: Error Rules with %sysmonth%

#5 Post by Heracles44 » 30 Aug 2021, 22:37

This don’t work too:

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

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Error Rules with %sysmonth%

#6 Post by TD-er » 30 Aug 2021, 22:47

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.

Heracles44
New user
Posts: 4
Joined: 30 Aug 2021, 08:05

Re: Error Rules with %sysmonth%

#7 Post by Heracles44 » 30 Aug 2021, 23:07

I’ve right. It’s me.

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

I’m stupid lol

TD-er
Core team member
Posts: 8642
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Error Rules with %sysmonth%

#8 Post by TD-er » 31 Aug 2021, 20:21

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)

Post Reply

Who is online

Users browsing this forum: No registered users and 27 guests