param: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(still wip)
 
(wip)
Line 3: Line 3:


| arma3dev |= Game name
| arma3dev |= Game name
|1.47|= Game version
|1.47|= Game version


Line 10: Line 11:
<br><br>
<br><br>
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. To log these substitutes into ''.rpt'' file, set [[Description.ext#allowFunctionsLog | allowFunctionsLog]] param in [[description.ext]] to 1.
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. To log these substitutes into ''.rpt'' file, set [[Description.ext#allowFunctionsLog | allowFunctionsLog]] param in [[description.ext]] to 1.
{{warning | W.I.P.}}  
{{warning | W.I.P.}} |= Description
|= Description
____________________________________________________________________________________________
____________________________________________________________________________________________


| [[param]] [index, defaultValue, expectedTypes, expectedArrayLength] |= Syntax
| [[param]] [index, defaultValue, expectedTypes, expectedArrayCount] |= Syntax




|p1= [index, defaultValue, expectedDataTypes, expectedArrayLength]: [[Array]]|=
|p1= [index, defaultValue, expectedDataTypes, expectedArrayCount]: [[Array]]|=
|p2= index: [[Number]] - index of required item in the input array.|=
|p2= index: [[Number]] - index of required item in the input array.|=
|p3= defaultValue: [[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).|=
|p3= 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).|=
|p4= expectedDataTypes (Optional): [[Array]] of direct [[Data Types]] - check if passed value is of listed [[Data Types]]. If not, use default value supplied. Empty array [] means every data type is accepted.|=
|p4= 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.|=
|p5= expectedArrayLength (Optional): [[Number]] - if passed value is array, check that it is of a certain length. If not, use default value supplied. |=
|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. |= Return value
| [[Anything]] - extracted value on success or default value otherwise. [[Nothing]] if syntax error occurred. |= Return value


| s2= argument [[param]] [index, defaultValue, expectedDataTypes, expectedArrayLength] |= Syntax
| s2= argument [[param]] [index, defaultValue, expectedDataTypes, expectedArrayCount] |= Syntax


|p21= argument: [[Anything]] - A usual array of params is expected. If a non-array value is passed, it will be converted to 1 element array |=
|p21= argument: [[Anything]] - A usual array of params is expected. If a non-array value is passed, it will be converted to 1 element array |=
|p22= [index, defaultValue, expectedDataTypes, expectedArrayLength]: [[Array]]||=
|p22= [index, defaultValue, expectedDataTypes, expectedArrayCount]: [[Array]]||=
|p23= index: [[Number]] - index of required item in the input array.|=
|p23= index: [[Number]] - index of required item in the input array.|=
|p24= defaultValue: [[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).|=
|p24= 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).|=
|p25= expectedDataTypes (Optional): [[Array]] of direct [[Data Types]] - check if passed value is one of listed [[Data Types]]. If not, use default value supplied. Empty array [] means every data type is accepted.|=
|p25= 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.|=
|p26= expectedArrayLength (Optional): [[Number]] - if passed value is an array, check that it is of a certain length. If not, use default value supplied. |=
|p26= 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. |=
| r2 = [[Anything]] - extracted value on success or default value otherwise. [[Nothing]] if syntax error occurred. |= Return value
|r2= [[Anything]] - extracted value on success or default value otherwise. [[Nothing]] if syntax error occurred. |= Return value
____________________________________________________________________________________________
____________________________________________________________________________________________
   
   
Line 58: Line 58:
[[hint]] "YOU ARE FLYING!";
[[hint]] "YOU ARE FLYING!";
};</code> |=
};</code> |=


|x4= <code>fnc = {
|x4= <code>fnc = {
[[private]] ["_pos", "_rad"]
[[private]] ["_pos", "_rad"]
_pos = [[param]] [0, [0,0,0], <nowiki>[</nowiki>[[objNull]], []], 3];
_pos = [[param]] [0, [0,0,0], <nowiki>[</nowiki>[[objNull]], []], [2,3]];
_rad = [[param]] [1, 0, [0]];
_rad = [[param]] [1, 0, [0]];
_pos [[nearObjects]] _rad;
_pos [[nearObjects]] _rad;
Line 69: Line 70:
<nowiki>[</nowiki>[[player]], 25] [[call]] fnc; //ok
<nowiki>[</nowiki>[[player]], 25] [[call]] fnc; //ok
[25, [[player]]] [[call]] fnc; //default values are used </code> |=
[25, [[player]]] [[call]] fnc; //default values are used </code> |=
____________________________________________________________________________________________
____________________________________________________________________________________________



Revision as of 18:59, 9 June 2015

-wrong parameter ("arma3dev") defined!-[[:Category:Introduced with arma3dev version 1.47|1.47]]
Hover & click on the images for description

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. To log these substitutes into .rpt file, set allowFunctionsLog param in description.ext to 1.
W.I.P.
Groups:
Uncategorised

Syntax

Syntax:
param [index, defaultValue, expectedTypes, 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", "_two", "_three"]; _one = param [0, 1]; _two = param [1, 2]; _three = param [2, 3]; // ..... };
Example 2:
[123] call { private "_val"; _val = param [0, 0]; }; // Below would produce the same result as above 123 call { private "_val"; _val = param [0, 0]; };
Example 3:
_z = position player param [2, 0]; if (_z > 10) then { hint "YOU ARE FLYING!"; };
Example 4:
fnc = { private ["_pos", "_rad"] _pos = param [0, [0,0,0], [objNull, []], [2,3]]; _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:
See also needed

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

[[Category:Introduced with arma3dev version 1.47]][[ Category: arma3dev: New Scripting Commands | PARAM]][[ Category: arma3dev: Scripting Commands | PARAM]]