Turn Script "If" question
chaosdagger
31 May 2015, 07:53Alright so here's what I'm trying to do, I have two attributes (numbers) that are going to change what message gets printed.
What I need to do is create multiple situations of "if (this number is between 40 and 50) and (this number is between 20 and 30) then print such and such."
I just don't understand how to get it to register if a number is any number between those... I hope you understand.
What I need to do is create multiple situations of "if (this number is between 40 and 50) and (this number is between 20 and 30) then print such and such."
I just don't understand how to get it to register if a number is any number between those... I hope you understand.

jaynabonne
31 May 2015, 08:21To translate what you said directly into an expression, you'd have:
You could also do this:
And then use it like:
which might be easier to read.
if (value1 >= 40 and value1 <= 50 and value2 >= 20 and value2 <= 30) {
msg("such and such")
}
You could also do this:
<function name="IsBetween" parameters="value, min, max" type="boolean"><![CDATA[
return (value >= min and value <= max)
]]></function>
And then use it like:
if (IsBetween(value1, 40, 50) and IsBetween(value, 20, 30)) {
msg("such and such")
}
which might be easier to read.
chaosdagger
31 May 2015, 08:34Thank you for the help ^^

jaynabonne
31 May 2015, 09:05I forgot the CDATA in the above. It has been corrected now.
chaosdagger
31 May 2015, 14:19Thanks again! I normally use the GUI view since I'm a complete newb however I figured out how to add this in code view without messing anything up.

jaynabonne
31 May 2015, 15:39Cool! 
