BIS fnc param: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Generated by BIS_fnc_exportFunctionsToWiki)
 
(Created page with "{{Function|= Comments ____________________________________________________________________________________________ | TKOH |= Game name |1.00|= Game version ____________________...")
Line 1: Line 1:
{{Function|= Comments
{{Function|= Comments
____________________________________________________________________________________________
____________________________________________________________________________________________


| tkoh |= Game name
| TKOH |= Game name


|1.00|= Game version
|1.00|= Game version
____________________________________________________________________________________________
____________________________________________________________________________________________


| <pre>/*
| Define script parameter. |= Description
____________________________________________________________________________________________


Description:
| [input,index,(defaultValue,dataTypes,requiredCount)] call bis_fnc_param; |= Syntax
Define script parameter


Parameter(s):
|p1= input: [[Array]] - list of params |= Parameter 1
_this select 0: ARRAY - list of params
_this select 1: NUMBER - selected index
_this select 2 (Optional): ANY - default param (used when param is missing or of wrong type)
- you can overload default value by setting 'BIS_fnc_<functionName>_<index>'
_this select 3 (Optional): ARRAY - list of allowed type examples (e.g. ["",[],0,objnull])
_this select 4 (Optional): NUMBER - If value is ARRAY, checks if it has required number of elements


Returns:
|p2= index: [[Number]] - selected index |= Parameter 2
ANY - either value from list of params, or default value
*/


///////////////////////////////////////////////////////////////////////////////////////////////////////////
|p3= defaultValue (Optional): [[Anything]] - default param (used when param is missing or of wrong type). You can overload default value by setting 'BIS_fnc_<functionName>_<index>' |= Parameter 2


#define FNC_DISABLEERRORS \
|p4= dataTypes (Optional): [[Array]] - list of allowed type examples (e.g. ["",[],0,objnull]) |= Parameter 2
private ["_disableErrors"]; \
_disableErrors = false;


// _disableErrors = if (count _this > 5) then {_this select 4} else {false};
|p5= requiredCount (Optional): [[Number]] - If value is Array, checks if it has required number of elements |= Parameter 2


#define FNC_TEXTTYPES \
| [[Anything]] |= Return value
private ["_textTypes"];\
_textTypes = "";\
{\
_textTypes = _textTypes + typename _x;\
if (_forEachIndex < count _types - 1) then {_textTypes = _textTypes + ", "};\
} foreach _types;
 
///////////////////////////////////////////////////////////////////////////////////////////////////////////
 
</pre><small>''(Placeholder description extracted from the function header by [[BIS_fnc_exportFunctionsToWiki]])''</small> |= Description
____________________________________________________________________________________________
____________________________________________________________________________________________
 
|x1= <code>_target <nowiki>=</nowiki> [_this, 0, [[objNull]], [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


| <!-- [] call [[BIS_fnc_param]]; --> |= Syntax
|x2= <code>_answer <nowiki>=</nowiki> [_this, 1, 42] call bis_fnc_param;</code>
 
* If (_this select 0) is not defined, default 42 is used.
|p1= |= Parameter 1
* No limit for data types or number of elements exists.
 
|= Example 1
| |= Return value
____________________________________________________________________________________________
 
|x1= <code></code> |=
____________________________________________________________________________________________
____________________________________________________________________________________________


Line 68: Line 49:


<h3 style="display:none">Bottom Section</h3>
<h3 style="display:none">Bottom Section</h3>
[[Category:Function Group: Debug|{{uc:param}}]]
 
[[Category:Functions|{{uc:param}}]]
[[Category:Take_On_Helicopters:_Functions|{{uc:{{PAGENAME}}}}]]
[[Category:{{Name|tkoh}}: Functions|{{uc:param}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:param}}]]

Revision as of 14:17, 20 October 2011

Hover & click on the images for description

Description

Description:
Define script parameter.
Execution:
call
Groups:
Uncategorised

Syntax

Syntax:
[input,index,(defaultValue,dataTypes,requiredCount)] call bis_fnc_param;
Parameters:
input: Array - list of params
index: Number - selected index
defaultValue (Optional): Anything - default param (used when param is missing or of wrong type). You can overload default value by setting 'BIS_fnc_<functionName>_<index>'
dataTypes (Optional): Array - list of allowed type examples (e.g. ["",[],0,objnull])
requiredCount (Optional): Number - 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's 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 0) is not defined, default 42 is used.
  • No limit for data types or number of elements exists.
  • 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

    Notes

    Bottom Section