Seite drucken - Counter-camparison in Dispatcher?

windigipet.de

Win-Digipet - international => Win-Digipet Forum English => Thema gestartet von: Per Olsen in 27. März 2022, 08:49:02

Titel: Counter-camparison in Dispatcher?
Beitrag von: Per Olsen in 27. März 2022, 08:49:02
Hello.

Is there a way (in Dispatcher) to compare 2 counters, and if the difference between them is a certain value, do the action? I cannot figure it out :) 

I use counters a lot, and love them :)  but I haven't found how to do just this :)  Is it possible?

Best regards,
Per
Titel: Re: Counter-camparison in Dispatcher?
Beitrag von: Bernd Senger in 27. März 2022, 11:44:06
Hi Per,

sure, you can do that. Within the dispatcher you'll find the condition "counter comparism" (expertmode is mandatory). Here you are able to set the conditions between two counters (e.g. not-equal). The corresponding action in your case could be "counter calculation".
Titel: Re: Counter-camparison in Dispatcher?
Beitrag von: Per Olsen in 27. März 2022, 11:51:57
Hello!

Thank you.  I already know this.  This works if the 2 counters are equal, or if one is bigger (smaller) than the other.  But I want this to be true ONLY if the difference between the two, are for example 4.  Can I do that?

Regards,
Per.
Titel: Re: Counter-camparison in Dispatcher?
Beitrag von: Stefan Lersch in 27. März 2022, 15:10:14
Hello Per,

I don't have WDP open right now but I would use a third counter. This counter is always the second counter minus 4. Now you can compare the first and the third counter.
Titel: Re: Counter-camparison in Dispatcher?
Beitrag von: Per Olsen in 27. März 2022, 16:07:12
Hello, Stefan!

Yes, I was thinking something like that myself.  But I was hoping there was an easier way :)

Regards,
Per.
Titel: Re: Counter-camparison in Dispatcher?
Beitrag von: Per Olsen in 28. März 2022, 23:03:13

Stefan, can you show me an example?  I am actually struggling with this..

Regards,
Per.
Titel: Re: Counter-camparison in Dispatcher?
Beitrag von: Per Olsen in 29. März 2022, 08:09:29
Hi again.

My problem is:  How do I make "Counter 2" always 4 (or any other value) higher (or lower) "Counter 1" ?  To be true always when "Counter 1" changes value.

Regards,
Per.
Titel: Re: Counter-camparison in Dispatcher?
Beitrag von: Stefan Lersch in 29. März 2022, 22:36:48
Hi Per,


I'm a little short of time at the moment. But I will think about your problem.
Titel: Re: Counter-camparison in Dispatcher?
Beitrag von: Stefan Lersch in 30. März 2022, 07:30:35
Hi Per,

I found the solution yesterday when lying in my bed. :) The point is that a dispatcher fires only if a condition becomes true. It does not fire if it is already true. Counter 1 is your starting point and counter 2 should be counter 1 plus 4. So you need a condition that changes when you change counter 1.

You need 4 counters. There are the above mentioned counters 1 and 2 and then there are the helpers 1 and 2. Helper 2 is always 4. Helper 1 stores the last value of counter 1.

So at the beginning counter 1 and helper 1 have the same value. In the dispatcher you compare the values of counter 1 and helper 1. If you change the value of counter 1 the dispatcher will fire. It will set counter 2 to the value of counter 1. Then it will add the value of helper 2 (here: 4) on top. Finally helper 1 is set to the value of counter 1.

So this will add 4 as you wished and it will always fire whenever you change the value of counter 1. See attechments.
Titel: Re: Counter-camparison in Dispatcher?
Beitrag von: Per Olsen in 30. März 2022, 10:02:45
Hello.

Yes, I know it fires only when there is a change. 
I tested your suggestion, and it works fine!  So now I will implement it to my layout.  It should work nicely :)

Thanks again, for super help, Stefan!

Best regards,
Per.