Welcome to %s forums

BrainModular Users Forum

Login Register

Scripting Conditional Statements with Logical Expression

I need help on a Patch
Post Reply
sephult
Member
Posts: 1144
Contact:

Unread post by sephult » 28 Aug 2016, 18:28

Hi All!

I was wondering if anyone else found issues when trying logical expressions like "and" , "or" ?

Example:
if (value > 12)and(value < 24) = true then begin


I can't seem to figure out why I keep running into problems and it will not enter my condition.
Any guesses?

-s
"Every act of creation is first an act of destruction." -Picasso

sephult
Member
Posts: 1144
Contact:

Unread post by sephult » 28 Aug 2016, 18:31

Well I guess I solved my issue:

FYI

if (value > 12)and(value < 24) = true then begin

should be

if (value > 12)and(value < 24) then begin

because the boolean is assumed and doesn't need to be defined for the condition.

-s
"Every act of creation is first an act of destruction." -Picasso

ahonoe
Member
Posts: 161
Location: Toronto
Contact:

Unread post by ahonoe » 28 Aug 2016, 22:40

That's correct. You also want to enclose the entire conditional part of the statement in parentheses:

if ((value > 12)and(value < 24)) then begin

I've learned that this gives more consistent results.
Regards,

Scott

sephult
Member
Posts: 1144
Contact:

Unread post by sephult » 30 Aug 2016, 00:13

Thanks ahonoe,

I kept running into this on many times and couldnt figure out why...lol
Glad finally figured out, makes life easier when scripting.

-s
"Every act of creation is first an act of destruction." -Picasso

shawnb
Member
Posts: 190
Location: San Francisco
Contact:

Unread post by shawnb » 01 Sep 2016, 02:30

True & False do not work as expected... Comparing them to conditions compiles clean, but always returns false.
Address the process rather than the outcome. Then, the outcome becomes more likely. - Fripp

shawnb
Member
Posts: 190
Location: San Francisco
Contact:

Unread post by shawnb » 01 Sep 2016, 04:40

Oddly, comparing them to 1 and 0 seems to work.
Just not conditions.
Address the process rather than the outcome. Then, the outcome becomes more likely. - Fripp

sephult
Member
Posts: 1144
Contact:

Unread post by sephult » 01 Sep 2016, 12:13

I agree shawnb, that's where I was getting confused. I am so used to doing the comparison and defining the result, I didn't expect that a boolean wouldn't need an expected result defined.

-s
"Every act of creation is first an act of destruction." -Picasso

Post Reply

Who is online

Users browsing this forum: No registered users and 83 guests