param: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Some wiki formatting) |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
Line 16: | Line 16: | ||
|p1= index: [[Number]] - index of required item in the input array. | |p1= index: [[Number]] - index of required item in the input array. | ||
|p2= defaultValue | |p2= 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). | ||
|p3= expectedDataTypes | |p3= expectedDataTypes: [[Array]] of direct [[:Category: Data Types| Data Types]] - (Optional) 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= expectedArrayCount | |p4= 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. | ||
|r1= [[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. | ||
Line 30: | Line 30: | ||
|p22= index: [[Number]] - index of required item in the input array. | |p22= index: [[Number]] - index of required item in the input array. | ||
|p23= defaultValue | |p23= 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). | ||
|p24= expectedDataTypes | |p24= expectedDataTypes: [[Array]] of direct [[:Category: Data Types| Data Types]] - (Optional) 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. | ||
|p25= expectedArrayCount | |p25= 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. | ||
|r2= [[Anything]] - extracted value on success or default value otherwise. [[Nothing]] if syntax error occurred. | |r2= [[Anything]] - extracted value on success or default value otherwise. [[Nothing]] if syntax error occurred. |
Revision as of 02:20, 1 August 2022
Description
- 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.
If 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. - Groups:
- VariablesArrays
Syntax
- Syntax:
- param [index, defaultValue, expectedDataTypes, expectedArrayCount]
- Parameters:
- index: Number - index of required item in the input array.
- 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).
- 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.
- 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.
- 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: Number - index of required item in the input array.
- 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).
- 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.
- 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.
- Return Value:
- Anything - extracted value on success or default value otherwise. Nothing if syntax error occurred.
Examples
- Example 1:
- Example 2:
- Example 3:
- Example 4:
Additional Information
- 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
-
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