A question about expression

Post your questions and help other users.

Moderator: Martin

Post Reply
rsegoly
Posts: 46
Joined: 14 Jun 2013 15:30

A question about expression

Post by rsegoly » 02 Feb 2014 21:28

If I get this message from nma as broadcast, how do i refer to it in condition expression? Since the number value will change from time to time


Its above threshold:
933

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: A question about expression

Post by Martin » 03 Feb 2014 17:43

You can extract the number in the message in different ways and compare the value. Something like this should work in a condition Expression:

Code: Select all

//simulate nma message
m = "Its above threshold:\n933";

//find the index of the first colon
i = indexOf(m, ":");

//extract the value (position of the colon + 2 to skip the colon and the newline characters)
value = substring(m, i + 2);

//test whether or not the value is bigger than 900
//determines whether the condition is true/false since it is the last statement in the condition
val>900;

rsegoly
Posts: 46
Joined: 14 Jun 2013 15:30

Re: A question about expression

Post by rsegoly » 03 Feb 2014 17:46

Thanks, as I also initiate the message I found it was easier just to send the number

Post Reply