# Simple syntax question: using "if" with "and"

## Recommended Posts

I can't believe I can't find the answer to this...maybe it's not possible.

I just want to have a multi-condition like this:

```if (_size >= 11) and (_size <= 50)  then...
```

And I can't seem to find the answer anywhere. How do you put two conditions in an If statement? Could I do:

```if (11<_size>=50) then...
```

or something like that???

##### Share on other sites

if ((_size >= 11) and (_size >= 50)) then {

##### Share on other sites
Myke;1824099']if ((_size >= 11) and (_size >= 50)) then {

Thanks! It was making me crazy! I thought there should be a way to do that.

##### Share on other sites
I can't believe I can't find the answer to this...maybe it's not possible.

I just want to have a multi-condition like this:

```if (_size >= 11) and (_size <= 50)  then...
```

And I can't seem to find the answer anywhere. How do you put two conditions in an If statement? Could I do:

```if (11<_size>=50) then...
```

or something like that???

not to say the way the above poster says to do it is wrong, but the proper way to 'and' something, and receive a boolean in return, is using:

```if (_size >= 11 && _size <= 50) then
{
...
}```

inversely, the or operation is:

```if (_size >= 11 || _size <= 50) then
{
...
}```

EDIT: actually, here is a link that might help you. specifically for boolean operations, look under the section that starts with '#' Arma2 scripting commands

Edited by GDICommand

##### Share on other sites
not to say the way the above poster says to do it is wrong, but the proper way to 'and' something, and receive a boolean in return, is using: ...

Proper way...

http://community.bistudio.com/wiki/and

Both ways work and you need to decide for yourself which way do you like.

##### Share on other sites
Proper way...

http://community.bistudio.com/wiki/and

Both ways work and you need to decide for yourself which way do you like.

the reason why i said it's the proper way, is because if you go past mission creating and go to learn an actual language, 'and' is not a keyword for any language ive encountered. '&&' is what is used (c, c++, Java, c#, etc). so id rather teach how to use booleans, rather than use what arma considers a keyword

##### Share on other sites

I think it might stem from SQS which is sort of a VB derivative (spiritually speaking), and VB uses AND. I personally prefer && since I come from a C background, but either works the same for SQF.

Edited by AZCoder

##### Share on other sites

If you guys wanted to debate "proper", you'd simply advise which way was interpreted and executed fastest in ArmA2 ! :rolleyes:

##### Share on other sites
Gnat;1824362']If you guys wanted to debate "proper"' date=' you'd simply advise [b']which way was interpreted and executed fastest[/b] in ArmA2 ! :rolleyes:

which is && correct?

I just use && and || for statements as I learned that in other languages and it's relevant there as well.

##### Share on other sites

They should be equivalent in speed, at least if implemented correctly ...

##### Share on other sites
They should be equivalent in speed, at least if implemented correctly ...

IIRC the engine is coded in C++ right? && and || are directly used in C++ so maybe the engine wouldn't have to interpret it and it could directly use it.

I'm just talking out of my ass. I'm not sure how the engine works at all lol.

##### Share on other sites

I dont know. BIS wrote the base code, so justifying speed using another system example (like C++) may not be valid.

Challenge for a uber environmental scripter;

Write a test script to prove one way or the other.