Check availability of eventvalue possible?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Micha_he
Normal user
Posts: 372
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Check availability of eventvalue possible?

#1 Post by Micha_he » 25 Aug 2020, 08:36

What's the recommended way, to check if the eventvalue contains a value ?

Code: Select all

on eventname do
  if %eventvalue1%=0
    (do something)
  endif
endon
Check for zero seems not work! Can I check for undefined?

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

Re: Check availability of eventvalue possible?

#2 Post by TD-er » 25 Aug 2020, 17:21

I think the event value will be 0 when not set.
But I do see the use case where it may be practical to have a "Not Set" value.

Micha_he
Normal user
Posts: 372
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Check availability of eventvalue possible?

#3 Post by Micha_he » 25 Aug 2020, 18:19

No, it's not 0! The result between:

Event,Eventname

and

Event,Eventname=0 is different. The if-condition isn't true. Also the check '<1' is not true, if no eentvalue is given.

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

Re: Check availability of eventvalue possible?

#4 Post by TD-er » 25 Aug 2020, 18:34

Ah that's interesting.
Have to look into the code to see why.
Maybe it is also trying to match the "=" sign when searching for the on...do block.

But if you refer to the %eventvalue%, then that one should be 0 when not set.... I think :)

User avatar
ThomasB
Normal user
Posts: 1065
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Check availability of eventvalue possible?

#5 Post by ThomasB » 25 Aug 2020, 20:13

If you are trying to trap an event without a value, then I propose this rule:

Code: Select all

on eventname do
  if %eventvalue%<=0 or %eventvalue%>0
    // (value provided, do something with the value)
  else 
    // (value NOT provided, do some default action)
  endif
endon
I tested this on mega-20200222 and it worked for me.

- Thomas

Micha_he
Normal user
Posts: 372
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

Re: Check availability of eventvalue possible?

#6 Post by Micha_he » 25 Aug 2020, 20:38

Nice workaround. Works with %eventvalue1% also. Thanks.

User avatar
ThomasB
Normal user
Posts: 1065
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Check availability of eventvalue possible?

#7 Post by ThomasB » 25 Aug 2020, 20:59

Nice workaround. Works with %eventvalue1% also. Thanks.
You're welcome. Glad to hear it is working for you.

FWIW, %eventvalue1% is an alias for %eventvalue%. Both are interchangeable.
But if you refer to the %eventvalue%, then that one should be 0 when not set.... I think
There are probably some applications that can benefit from knowing when the eventvalue has not been assigned. So defaulting it to zero would prevent that. I'd recommend leaving things as-is. Or if preferred, allow the rules to test for %NULL% (unassigned) values.

- Thomas

Post Reply

Who is online

Users browsing this forum: No registered users and 102 guests