param: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - " \| *(([^=\| ]+)('''|\[\[)([^=\| ]+)) * +\|p1=" to " |s1= $1 |p1=") |
Lou Montana (talk | contribs) m (Text replacement - " \| *([^= ]+) * +\|s2=" to " |r1=$1 |s2=") |
||
Line 21: | Line 21: | ||
|p4= expectedDataTypes (Optional): [[Array]] of direct [[:Category: Data Types| Data Types]] - checks if passed value is one of listed [[:Category: Data Types| Data Types]]. If not, default value is used instead. Empty array [] means every data type is accepted. | |p4= expectedDataTypes (Optional): [[Array]] of direct [[:Category: Data Types| Data Types]] - checks if passed value is one of listed [[:Category: Data Types| Data Types]]. If not, default value is used instead. Empty array [] means every data type is accepted. | ||
|p5= expectedArrayCount (Optional): [[Number]] or [[Array]] - 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. | |p5= expectedArrayCount (Optional): [[Number]] or [[Array]] - 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. | ||
| [[Anything]] - extracted value on success or default value otherwise. [[Nothing]] if syntax error occurred. | |r1= [[Anything]] - extracted value on success or default value otherwise. [[Nothing]] if syntax error occurred. | ||
|s2= argument [[param]] [index, defaultValue, expectedDataTypes, expectedArrayCount] | |s2= argument [[param]] [index, defaultValue, expectedDataTypes, expectedArrayCount] |
Revision as of 00:19, 13 June 2021
Description
- Description:
- Description needed
- Groups:
- VariablesArrays
Syntax
- Syntax:
- param [index, defaultValue, expectedDataTypes, expectedArrayCount]
- Parameters:
- [index, defaultValue, expectedDataTypes, expectedArrayCount]: Array
- index: Number - index of required item in the input array.
- defaultValue (Optional): Anything - a default value to return if input is undefined, of the wrong type or of the wrong length (if the item is an array).
- expectedDataTypes (Optional): Array of direct Data Types - 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.
- expectedArrayCount (Optional): Number or Array - 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.
- Return Value:
- Anything - extracted value on success or default value otherwise. Nothing if syntax error occurred.
Alternative Syntax
- Syntax:
- argument param [index, defaultValue, expectedDataTypes, expectedArrayCount]
- Parameters:
- argument: Anything - A usual array of params is expected. If a non-array value is passed, it will be converted to 1 element array
- [index, defaultValue, expectedDataTypes, expectedArrayCount]: Array
- index: Number - index of required item in the input array.
- defaultValue (Optional): Anything - a default value to return if input is undefined, of the wrong type or of the wrong length (if the item is an array).
- expectedDataTypes (Optional): Array of direct Data Types - 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.
- expectedArrayCount (Optional): Number or Array - 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.
- Return Value:
- Anything - extracted value on success or default value otherwise. Nothing if syntax error occurred.
Examples
- Example 1:
[1, 2, 3] call { private _one = param [0, 1]; private _two = param [1, 2]; private _three = param [2, 3]; // ... };
- Example 2:
[123] call { private _val = param [0]; }; // Below would produce the same result as above 123 call { private _val = param [0]; };
- Example 3:
_z = position player param [2, 0]; if (_z > 10) then { hint "YOU ARE FLYING!"; };
- Example 4:
fnc = { private _pos = param [0, [0,0,0], [objNull, []], [2,3]]; private _rad = param [1, 0, [0]]; _pos nearObjects _rad; }; [position player, 25] call fnc; // ok [player, 25] call fnc; // ok [25, player] call fnc; // default values are used
Additional Information
- See also:
- paramsselectsetresizereverseinfindfindIftoArraytoStringforEachcountdeleteAtdeleteRangeappendsortarrayIntersectsplitStringjoinStringisEqualTypeAllisEqualTypeisEqualTypeParamsisEqualTypeArrayisEqualTypeAnytypeNameBIS_fnc_param
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note