Exception handling – Talk

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
Line 5: Line 5:
== firebomb.sqs example ==
== firebomb.sqs example ==
The first if in the '''firebomb.sqs'' example is incorrect.
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)
you are using a || = conditional OR here, so the code ''throw "vehicle empty"'' will be executed if one of the conditions returns true. your intention was to get this code exectued when there is nobody in the vehicle, so you should use && = conditional OR. Additionaly, this code is unnecessary. a simple (crew vehicle == 0) would be much more effective. --[[User:TeRp|TeRp]] 20:40, 22 July 2006 (CEST)

Revision as of 19:41, 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 one of the conditions returns true. your intention was to get this code exectued when there is nobody in the vehicle, so you should use && = conditional OR. Additionaly, this code is unnecessary. a simple (crew vehicle == 0) would be much more effective. --TeRp 20:40, 22 July 2006 (CEST)