{"name":"assert","operator":null,"title":"assert","type":"command","url":"https://community.bistudio.com/wiki/assert","revid":363603,"updated":"2024-04-08T09:49:06Z","groups":["Program Flow"],"status":"ok","replaced_by":[],"games":[{"game":"arma1","name":"Armed Assault","version":"1.00"},{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma1","name":"Armed Assault","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Tests a condition and if the condition is false, displays error on screen (if -showscripterrors enabled) and logs error into .rpt file. It does not interrupt the script execution.\n\nIf script was pre-processed with preprocessFileLineNumbers, it will also show/log the error line number and the file name.","syntaxes":[{"syntax":"assert condition","since":null,"effect":null,"exec":null,"params":[{"name":"condition","type":"Boolean","optional":false,"default":null,"description":null,"types":["Boolean"],"since":null,"text":"condition: Boolean"}],"returns":{"type":"Boolean","types":["Boolean"],"description":"mirrors condition","text":"Boolean - mirrors condition"},"form":"unary","operator":null,"left":null,"right":{"text":"condition","types":["Boolean"]}}],"examples":[{"text":"```sqf\nassert (1 > 2);\n```","code":["assert (1 > 2);"]},{"text":"Check function params (Faster alternative to BIS_fnc_param)\n\n```sqf\nsome_func = {\n    _0 = _this select 0;\n    _1 = _this select 1;\n    _2 = _this select 2;\n    if (!assert (\n        typeName _0 == \"ARRAY\" && \n        typeName _1 == \"STRING\" &&\n        typeName _2 == \"SCALAR\"\n    )) exitWith { /* optional error logging */ };\n    hint \"Alright!\";\n};\n[1,2,3] call some_func; // assert error\n[[1],\"2\",3] call some_func; // Alright!\n```","code":["some_func = {\n\t_0 = _this select 0;\n\t_1 = _this select 1;\n\t_2 = _this select 2;\n\tif (!assert (\n\t\ttypeName _0 == \"ARRAY\" && \n\t\ttypeName _1 == \"STRING\" &&\n\t\ttypeName _2 == \"SCALAR\"\n\t)) exitWith { /* optional error logging */ };\n\thint \"Alright!\";\n};\n[1,2,3] call some_func; // assert error\n[[1],\"2\",3] call some_func; // Alright!"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["try","catch","throw","halt","diag_captureFrame","diag_captureSlowFrame","diag logSlowFrame"],"notes":[{"user":"RoehrenRadio","date":"2010-05-15T00:01:00Z","text":"Returns false, if condition is false, and returns true, if condition is true."}],"categories":["ArmA: Armed Assault: New Scripting Commands","ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Program Flow","Introduced with Armed Assault version 1.00","Scripting Commands","Take On Helicopters: Scripting Commands"]}