BIS fnc param: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(accepts array of sizes)
m (Text replacement - "(\|[pr][0-9]+ *= *[^- ]*) *- *S([a-z ])" to "$1 - s$2")
 
(48 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Function|= Comments
{{RV|type=function
____________________________________________________________________________________________


| arma3 |= Game name
|game1= tkoh
|version1= 1.00


|0.50|= Game version
|game2= arma3
____________________________________________________________________________________________
|version2= 0.50


| Load a script parameter. See [[Functions_Library (Arma_3)#Loading_Parameters|Functions Library (Arma 3)]] for detailed description. |= Description
|gr1= Arrays
____________________________________________________________________________________________


| [input,index,(defaultValue,dataTypes,requiredCount)] call [[BIS_fnc_param]]; |= Syntax
|descr= Load a script parameter. See [[Arma 3: Functions Library#Loading Parameters|Arma 3: Functions Library]] for detailed description.


|p1= input: [[Array]] - list of params |= Parameter 1
{{Feature|Arma3|Use [[param]] or [[params]] commands instead.}}


|p2= index: [[Number]] - selected index |= Parameter 2
|s1= [input, index, defaultValue, dataTypes, requiredCount] call [[BIS_fnc_param]]


|p3= defaultValue (Optional): [[Anything]] - default param (used when param is missing or of wrong type).<br />You can overload default value by declaring variable ''BIS_fnc_<functionName>_<index>'' in [[Namespace]] where BIS_fnc_param is called from.<br />[[BIS_fnc_paramIn]] is a variant of the function with overloading disabled. |= Parameter 2
|p1= input: [[Array]] - list of params


|p4= dataTypes (Optional): [[Array]] - list of allowed type examples (e.g. ["",[],0,[[objNull]]<nowiki>]</nowiki>) |= Parameter 2
|p2= index: [[Number]] - selected index


|p5= requiredCount (Optional): [[Number]] or [[Array]] - If value is Array, checks if it has required number of elements |= Parameter 2
|p3= defaultValue: [[Anything]] - (Optional, default [[Nothing]]) default param (used when param is missing or of wrong type).<br>You can overload default value by declaring variable ''BIS_fnc_<functionName>_<index>'' in [[Namespace]] where BIS_fnc_param is called from.<br>[[BIS_fnc_paramIn]] is a variant of the function with overloading disabled.


| [[Anything]] |= Return value
|p4= dataTypes: [[Array]] - (Optional, default [[Anything]]) list of allowed type examples (e.g. ["",[],0,[[objNull]]<nowiki>]</nowiki>)
____________________________________________________________________________________________
 
|x1= <code>_target <nowiki>=</nowiki> [_this, 0, [[objNull]], <nowiki>[</nowiki>[[objNull]],[]], [2,3]] [[call]] [[BIS_fnc_param]];</code>
* If (_this select 0) is not defined, default objnull is used.
* If (_this select 0) is defined, but is neither of type [[Object]] nor [[Array]], error message is logged and default [[objNull]] is used.
* If (_this select 0) and is [[Array]], but it's count is neither 2 nor 3, error message is logged and default [[objNull]] is used.
|= Example 1


|x2= <code>_answer <nowiki>=</nowiki> [_this, 1, 42] [[call]] [[BIS_fnc_param]];</code>
|p5= requiredCount: [[Number]] or [[Array]] - (Optional) if value is Array, checks if it has required number of elements
* If (_this select 1) is not defined, default 42 is used.
* No limit for data types or number of elements exists.
|= Example 1
____________________________________________________________________________________________


| [[BIS_fnc_paramIn]] |= See also
|r1= [[Anything]]


|x1= <sqf>_target = [_this, 0, objNull, [objNull,[]], [2,3]] call BIS_fnc_param;</sqf>
* if (_this select 0) is not defined, default objnull is used.
* if (_this select 0) is defined, but is neither of type [[Object]] nor [[Array]], error message is logged and default [[objNull]] is used.
* if (_this select 0) and is [[Array]], but it is count is neither 2 nor 3, error message is logged and default [[objNull]] is used.
|x2= <sqf>_answer = [_this, 1, 42] call BIS_fnc_param;</sqf>
* if (_this select 1) is not defined, default 42 is used.
* no limit for data types or number of elements exists.
|seealso= [[BIS_fnc_paramIn]] [[param]] [[params]]
}}
}}


<h3 style="display:none">Notes</h3>
{{Note
<dl class="command_description">
|user= ffur2007slx2_5
<!-- Note Section BEGIN -->
|timestamp= 20140906215500
<dd class="notedate">Posted: 21:55 Sep 6 2014</dd>
|text= {{GVI|arma3|1.28}} Use [[BIS_fnc_paramIn]] to load private path from parent parameters (loaded by [[BIS_fnc_param]])
<dt class="note">[[User:ffur2007slx2_5|ffur2007slx2_5]]</dt>
<sqf>
<dd class="note">(A3 1.28) Use [[BIS_fnc_paramIn]] to load private path from parent parameters (loaded by [[BIS_fnc_param]])
private ["_parent", "_child0", "_child1"];
<code>
_parent = [_this, 0, [], [[]]] call BIS_fnc_param;
[[private]] ["_parent","_child0","_child1"];
_child0 = [_parent, 0, missionNamespace, [missionNamespace, grpNull, objNull]] call BIS_fnc_paramIn;
_parent = [_this,0,[],[[]]] [[call]] [[BIS_fnc_param]];
_child1 = [_parent, 1, "", [""]] call BIS_fnc_paramIn;
_child0 = [_parent,0,[[missionNamespace]],[ [[missionNamespace]],[[grpNull]],[[objNull]] ]] [[call]] [[BIS_fnc_paramIn]];
</sqf>
_child1 = [_parent,1,"",[""]] [[call]] [[BIS_fnc_paramIn]];
}}
</code>
<!-- Note Section END -->
</dl>
 
<h3 style="display:none">Bottom Section</h3>
[[Category:Function Group: Debug|{{uc:param}}]]
[[Category:Functions|{{uc:param}}]]
[[Category:{{Name|tkoh}}: Functions|{{uc:param}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:param}}]]

Latest revision as of 16:49, 8 November 2023

Hover & click on the images for description

Description

Description:
Load a script parameter. See Arma 3: Functions Library for detailed description.
Arma 3
Use param or params commands instead.
Execution:
call
Groups:
Arrays

Syntax

Syntax:
[input, index, defaultValue, dataTypes, requiredCount] call BIS_fnc_param
Parameters:
input: Array - list of params
index: Number - selected index
defaultValue: Anything - (Optional, default Nothing) default param (used when param is missing or of wrong type).
You can overload default value by declaring variable BIS_fnc_<functionName>_<index> in Namespace where BIS_fnc_param is called from.
BIS_fnc_paramIn is a variant of the function with overloading disabled.
dataTypes: Array - (Optional, default Anything) list of allowed type examples (e.g. ["",[],0,objNull])
requiredCount: Number or Array - (Optional) if value is Array, checks if it has required number of elements
Return Value:
Anything

Examples

Example 1:
_target = [_this, 0, objNull, [objNull,[]], [2,3]] call BIS_fnc_param;
  • if (_this select 0) is not defined, default objnull is used.
  • if (_this select 0) is defined, but is neither of type Object nor Array, error message is logged and default objNull is used.
  • if (_this select 0) and is Array, but it is count is neither 2 nor 3, error message is logged and default objNull is used.
Example 2:
_answer = [_this, 1, 42] call BIS_fnc_param;
  • if (_this select 1) is not defined, default 42 is used.
  • no limit for data types or number of elements exists.
  • Additional Information

    See also:
    BIS_fnc_paramIn param params

    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
    ffur2007slx2_5 - c
    Posted on Sep 06, 2014 - 21:55 (UTC)
    Arma 3 logo black.png1.28 Use BIS_fnc_paramIn to load private path from parent parameters (loaded by BIS_fnc_param)
    private ["_parent", "_child0", "_child1"]; _parent = [_this, 0, [], [[]]] call BIS_fnc_param; _child0 = [_parent, 0, missionNamespace, [missionNamespace, grpNull, objNull]] call BIS_fnc_paramIn; _child1 = [_parent, 1, "", [""]] call BIS_fnc_paramIn;