Exception handling – Talk

From Bohemia Interactive Community
Jump to navigation Jump to search
(I changed my previous stupid answer)
No edit summary
Line 2: Line 2:


:IMHO every number larger than zero means true. --[[User:Djura|Djura]] 20:38, 22 July 2006 (CEST)
:IMHO every number larger than zero means true. --[[User:Djura|Djura]] 20:38, 22 July 2006 (CEST)
== firebomb.sqs example ==
The first if in the '''firebomb.sqs'' example is incorrect.
you are using a || = conditional OR here, so the code ''throw "vehicle empty"'' will be executed if there one of the conditions returns true. your intention was to get this code exectued when there is noone in the vehicle, so you should use && = conditional OR. Additionaly, this code is unnecessary. a simple (crew vehicle == 0) will be much more effective. --[[User:TeRp|TeRp]] 20:40, 22 July 2006 (CEST)

Revision as of 20:40, 22 July 2006

Can the if statement handle numbers? Because emptyPositions returns a number and not a boolean. --T_D 20:07, 22 July 2006 (CEST)

IMHO every number larger than zero means true. --Djura 20:38, 22 July 2006 (CEST)

firebomb.sqs example

The first if in the 'firebomb.sqs example is incorrect. you are using a || = conditional OR here, so the code throw "vehicle empty" will be executed if there one of the conditions returns true. your intention was to get this code exectued when there is noone in the vehicle, so you should use && = conditional OR. Additionaly, this code is unnecessary. a simple (crew vehicle == 0) will be much more effective. --TeRp 20:40, 22 July 2006 (CEST)