2 registered members (AndrewAMD, SBGuy),
987
guests, and 3
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Question about IF
#456458
11/23/15 19:31
11/23/15 19:31
|
Joined: Nov 2009
Posts: 201
Logitek
OP
Member
|
OP
Member
Joined: Nov 2009
Posts: 201
|
Hello, I have an interesting question about the IF command.
For example:
If (a == 1 && b == 1 && c == 1) {Do something}
Does the engine now proof each var, also if a is not 1? I mean: Does the engine break the line and is looking for the next command or does it also check b and c? Also if we already know that a is not 1 and it can not be end in true anymore?
It is interesting for scripts with a lot of IF commands. I think it is breaking the line, right?
Last edited by Logitek; 11/23/15 19:32.
|
|
|
Re: Question about IF
[Re: Logitek]
#456459
11/23/15 19:37
11/23/15 19:37
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
It should not check the following statements after encountering a false one in this situation, but it still does. It's easy to proof:
ENTITY *ent = NULL;
if(ent && ent->x == 0)
This is valid and every normal C compiler won't try to evaluate the second statement, however in Lite-C, you can enjoy a beautiful crash. It's documented somewhere in the manual.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Question about IF
[Re: Superku]
#456461
11/23/15 20:00
11/23/15 20:00
|
Malice
Unregistered
|
Malice
Unregistered
|
If (a == 1 && b == 1 && c == 1) if(a+b+c == 3) Lol just thought I write something. Mal
|
|
|
Re: Question about IF
[Re: jcl]
#456595
11/30/15 13:17
11/30/15 13:17
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
Yes. I admit that this is a clumsy way, but that's how the compiler works - and to change this to the normal C compiler standard is a major act, unfortunately. That's a pity but okay...
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
|