Choicescript help (if and variables)


#1

Need help with some coding.
This is what i have:

*if ((((Gender = "Male") or (Gender = "Female")) and (((background = "suburbs") and ((kind > funny) or (kind > mean))))

This is my error:

“Invalid expression, expected CLOSE_PARENTHESIS”


#2

Try

*if (((blah) and (blah2)) and (blah3))


#3

Thanks for the quick response :slight_smile:
But would that work with “or” as well?


#4

Yes, that should work with or as well.


#5

I tried it:

*if (((Gender = "Male") or (Gender = "Female")) and (background = "suburbs") and (kind > funny) or (kind > mean))

and i got this:

“Invalid expression at char 76, expected CLOSE_PARENTHESIS, was: NAMED_OPERATOR [and]”


#6

Try:

*if((Gender=“Male”) or ((Gender=“Female”) and (background=“suburbs”)) and ((kind > funny) or (kind>mean)))


#7

Right, with four variables it’s a bit different–takes some getting used to! I do my best to avoid four, actually, because the parenthesis get nutty.


#8

Thanks for helping out too :smiley:

I did as you said:

*if ((Gender = "Male") or ((Gender = "Female") and (background = "suburbs")) and ((kind > funny or kind > mean)))

I got the same error:

“Invalid expression at char 76, expected CLOSE_PARENTHESIS, was: NAMED_OPERATOR [and]”


#9

I know, but i have no idea how to do make it easier. I’m kind of new to this too.

I got the first right:

*if (((Gender = "Male") and (background = "village")) and ((mean > kind) or (mean > funny)))

I don’t think it gave me an error…


#10

I forgot “(” and “)” in a few places, edited it just now, sorry, I’m on the phone so it’s tricky to write a code :sweat_smile:


#11

No worries friend! I appreciate the help you’re giving.

The coding is like this now:

*if ((Gender = "Male") or ((Gender = "Female") and (background = "suburbs")) and ((kind > funny) or (kind > mean)))

And it seems i got the same error:

“Invalid expression at char 76, expected CLOSE_PARENTHESIS, was: NAMED_OPERATOR [and”

:frowning:


#12

Does this work?
*if (((Gender = “Male”) or (Gender = “Female”)) and (background = “suburbs”)) and ((kind > funny) or (kind > mean))

Otherwise, it really depends on what exactly are the units you’re using. For future reference, though, it can only handle two units at a time so what I like to do is bracket off the “or” parts first and combine them into one unit each, and then start bracketing the “and” statements together.


#13

IT WORKED! Thank you so much! <3
I would hug you if i could!

Maaan, i love this community… :smile:


#14

Hope this helps. Read down for an example combining ands with ors…


#15

Thank you so much for the reply, though I’ve already solved it thanks to some amazing people.
But thank you really for the explanation, I understand this better now!