{"name":"param","operator":null,"title":"param","type":"command","url":"https://community.bistudio.com/wiki/param","revid":369264,"updated":"2024-09-03T18:42:42Z","groups":["Variables","Arrays"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"1.48"}],"since":{"game":"arma3","name":"Arma 3","version":"1.48"},"arma3_since":"1.48","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Extracts a single value with given index from input argument, similar to BIS_fnc_param.  When used without argument, as shown in main syntax, internal variable _this, which is usually available inside functions and event handlers, is used as argument. If input argument is not an array, it will be converted to 1 element array.\n\nIf extracted item of input with given index is undefined, of the wrong type or of the wrong length (if the item is an array), default value is used instead. Since Arma 3 v1.54, onscreen errors are displayed for when the input is of the wrong type or size.","syntaxes":[{"syntax":"param [index, defaultValue, expectedDataTypes, expectedArrayCount]","since":null,"effect":null,"exec":null,"params":[{"name":"index","type":"Number","optional":false,"default":null,"description":"index of required item in the input array.","types":["Number"],"since":null,"text":"index: Number - index of required item in the input array."},{"name":"defaultValue","type":"Anything","optional":true,"default":null,"description":"a default value to return if input is undefined, of the wrong type or of the wrong length (if the item is an array).","types":["Anything"],"since":null,"text":"defaultValue: Anything - (Optional) a default value to return if input is undefined, of the wrong type or of the wrong length (if the item is an array)."},{"name":"expectedDataTypes","type":"Array of direct Data Types","optional":true,"default":null,"description":"checks if passed value is one of listed Data Types. If not, default value is used instead. Empty array [] means every data type is accepted.","types":["Array"],"since":null,"text":"expectedDataTypes: Array of direct Data Types - (Optional) checks if passed value is one of listed Data Types. If not, default value is used instead. Empty array [] means every data type is accepted."},{"name":"expectedArrayCount","type":"Number or Array","optional":true,"default":null,"description":"a single size or array of sizes. If passed input value is an array, checks that it has a certain number of elements. If not, default value is used instead. Empty array [] means any size is accepted.","types":["Number","Array"],"since":null,"text":"expectedArrayCount: Number or Array - (Optional) a single size or array of sizes. If passed input value is an array, checks that it has a certain number of elements. If not, default value is used instead. Empty array [] means any size is accepted."}],"returns":{"type":"Anything","types":["Anything"],"description":"extracted value on success or default value otherwise. Nothing if syntax error occurred.","text":"Anything - extracted value on success or default value otherwise. Nothing if syntax error occurred."},"form":"unary","operator":null,"left":null,"right":{"text":"[index, defaultValue, expectedDataTypes, expectedArrayCount]","types":["Array"]}},{"syntax":"argument param [index, defaultValue, expectedDataTypes, expectedArrayCount]","since":null,"effect":null,"exec":null,"params":[{"name":"argument","type":"Anything","optional":false,"default":null,"description":"a usual array of params is expected. If a non-array value is passed, it will be converted to 1 element array","types":["Anything"],"since":null,"text":"argument: Anything - a usual array of params is expected. If a non-array value is passed, it will be converted to 1 element array"},{"name":"index","type":"Number","optional":false,"default":null,"description":"index of required item in the input array.","types":["Number"],"since":null,"text":"index: Number - index of required item in the input array."},{"name":"defaultValue","type":"Anything","optional":true,"default":null,"description":"a default value to return if input is undefined, of the wrong type or of the wrong length (if the item is an array).","types":["Anything"],"since":null,"text":"defaultValue: Anything - (Optional) a default value to return if input is undefined, of the wrong type or of the wrong length (if the item is an array)."},{"name":"expectedDataTypes","type":"Array of direct Data Types","optional":true,"default":null,"description":"checks if passed value is one of listed Data Types. If not, default value is used instead. Empty array [] means every data type is accepted.","types":["Array"],"since":null,"text":"expectedDataTypes: Array of direct Data Types - (Optional) checks if passed value is one of listed Data Types. If not, default value is used instead. Empty array [] means every data type is accepted."},{"name":"expectedArrayCount","type":"Number or Array","optional":true,"default":null,"description":"a single size or array of sizes. If passed input value is an array, checks that it has a certain number of elements. If not, default value is used instead. Empty array [] means any size is accepted.","types":["Number","Array"],"since":null,"text":"expectedArrayCount: Number or Array - (Optional) a single size or array of sizes. If passed input value is an array, checks that it has a certain number of elements. If not, default value is used instead. Empty array [] means any size is accepted."}],"returns":{"type":"Anything","types":["Anything"],"description":"extracted value on success or default value otherwise. Nothing if syntax error occurred.","text":"Anything - extracted value on success or default value otherwise. Nothing if syntax error occurred."},"form":"binary","operator":null,"left":{"text":"argument","types":["Anything"]},"right":{"text":"[index, defaultValue, expectedDataTypes, expectedArrayCount]","types":["Array"]}}],"examples":[{"text":"```sqf\n[1, 2, 3] call \n{\n    private _one = param [0, 1];\n    private _two = param [1, 2];\n    private _three = param [2, 3];\n    // ...\n};\n```","code":["[1, 2, 3] call \n{\n\tprivate _one = param [0, 1];\n\tprivate _two = param [1, 2];\n\tprivate _three = param [2, 3];\n\t// ...\n};"]},{"text":"```sqf\n[123] call \n{\n    private _val = param [0];\n};\n\n// Below would produce the same result as above\n123 call \n{\n    private _val = param [0];\n};\n```","code":["[123] call \n{\n\tprivate _val = param [0];\n};\n\n// Below would produce the same result as above\n123 call \n{\n\tprivate _val = param [0];\n};"]},{"text":"```sqf\n_z = position player param [2, 0];\nif (_z > 10) then \n{\n    hint \"YOU ARE FLYING!\";\n};\n```","code":["_z = position player param [2, 0];\nif (_z > 10) then \n{\n\thint \"YOU ARE FLYING!\";\n};"]},{"text":"```sqf\nfnc = \n{\n    private _pos = param [0, [0,0,0], [objNull, []], [2,3]];\n    private _rad = param [1, 0, [0]];\n    _pos nearObjects _rad;\n};\n\n[position player, 25] call fnc; // ok\n[player, 25] call fnc; // ok\n[25, player] call fnc; // default values are used\n```","code":["fnc = \n{\n\tprivate _pos = param [0, [0,0,0], [objNull, []], [2,3]];\n\tprivate _rad = param [1, 0, [0]];\n\t_pos nearObjects _rad;\n};\n\n[position player, 25] call fnc; // ok\n[player, 25] call fnc; // ok\n[25, player] call fnc; // default values are used"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["params","select","set","resize","reverse","in","find","findIf","toArray","toString","forEach","count","deleteAt","deleteRange","append","sort","arrayIntersect","splitString","joinString","isEqualTypeAll","isEqualType","isEqualTypeParams","isEqualTypeArray","isEqualTypeAny","typeName","BIS_fnc_param"],"notes":[],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Arrays","Command Group: Variables","Introduced with Arma 3 version 1.48","Scripting Commands"]}