BIS fnc errorParamsType: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "|Game version=" to "|Game version= |gr1 = Debug |GROUP1=")
m (Text replacement - "(\|[pr][0-9]+ *= *[^-]+) *- *E([a-z])" to "$1 - e$2")
 
(20 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Function|Comments=
{{RV|type=function


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


|1.00|Game version=
|gr1= Diagnostic


|gr1 = Debug |GROUP1=
|eff= local


|eff= local |Multiplayer Effects=
|descr= Displays a parameter type error message (using [[BIS_fnc_error]]) explaining the problem.


| Displays a parameter type error message (using [[BIS_fnc_error]]) explaining the problem. |Description=
|s1= [value, method, expected] call [[BIS_fnc_errorParamsType]]


| [value, method, expected] call [[BIS_fnc_errorParamsType]] |Syntax=
|p1= '''value''': [[Anything]] - (Optional, default [[nil]]) value received.


|p1= value: [[Anything]] - (Optional, default [[nil]]) value received |Parameter 1=
|p2= '''method''': [[String]] - (Optional, default "") validation method, can be one of:
 
|p2= method: [[String]] - (Optional, default "") validation method, can be one of:
* "isEqualType"
* "isEqualType"
* "isEqualTypeArray"
* "isEqualTypeArray"
* "isEqualTypeAll"
* "isEqualTypeAll"
* "isEqualTypeAny"
* "isEqualTypeAny"
* "isEqualTypeParams" |Parameter 2=
* "isEqualTypeParams"


|p3= expected: [[Anything]] - (Optional, default [[nil]]) - expected type |Parameter 3=
|p3= '''expected''' (Optional, default: [[nil]]): [[Anything]] - expected type.


| [[Nothing]] |Return value=
|r1= [[Nothing]]


|x1= <code>{{cc|Show error and abort if input is not of type ARRAY}}
|x1= <sqf>
[[if]] !([[_this]] [[isEqualType]] []) [[exitWith]] { [<nowiki/>[[_this]], "isEqualType", []] [[call]] [[BIS_fnc_errorParamsType]] };</code> |Example 1=
// show error and abort if input is not of type ARRAY:
if !(_this isEqualType []) exitWith { [_this, "isEqualType", []] call BIS_fnc_errorParamsType; };
</sqf>


|x2= <code>{{cc|Show error and abort if array input is not in format [SCALAR, STRING, BOOL]}}
|x2= <sqf>
[[if]] !([[_this]] [[isEqualTypeArray]] [0, "", [[true]]]) [[exitWith]] { [<nowiki/>[[_this]], "isEqualTypeArray", [0, "", [[true]]]] [[call]] [[BIS_fnc_errorParamsType]] };</code> |Example 2=
// show error and abort if array input is not in format [SCALAR, STRING, BOOL]:
if !(_this isEqualTypeArray [0, "", true]) exitWith { [_this, "isEqualTypeArray", [0, "", true]] call BIS_fnc_errorParamsType; };
</sqf>


|x3= <code>{{cc|Show error and abort if array input is not in format [BOOL, BOOL, BOOL...]}}
|x3= <sqf>
[[if]] !([[_this]] [[isEqualTypeAll]] [[true]]) [[exitWith]] {[<nowiki/>[[_this]], "isEqualTypeAll", [[true]]] [[call]] [[BIS_fnc_errorParamsType]] };</code> |Example 3=
// show error and abort if array input is not in format [BOOL, BOOL, BOOL, ...]:
if !(_this isEqualTypeAll true) exitWith { [_this, "isEqualTypeAll", true] call BIS_fnc_errorParamsType; };
|x4= <code>{{cc|Show error and abort if input is neither ARRAY nor OBJECT}}
</sqf>
[[if]] !([[_this]] [[isEqualTypeAny]] [[], [[objNull]]]) [[exitWith]] { [<nowiki/>[[_this]], "isEqualTypeAny", [[], [[objNull]]]] [[call]] [[BIS_fnc_errorParamsType]] };</code> |Example 4=


|x5= <code>{{cc|Show error and abort if input is neither of type ARRAY nor array in format [SCALAR, ARRAY, <ANYTHING>, OBJECT....]}}
|x4= <sqf>
[[if]] !([[_this]] [[isEqualTypeParams]] [0, [], [[nil]], [[objNull]]]) [[exitWith]] { [<nowiki/>[[_this]], "isEqualTypeParams", [0, [], [[nil]], [[objNull]]]] [[call]] [[BIS_fnc_errorParamsType]]};</code> |Example 5=
// show error and abort if input is neither ARRAY nor OBJECT:
if !(_this isEqualTypeAny [[], objNull]) exitWith { [_this, "isEqualTypeAny", [[], objNull]] call BIS_fnc_errorParamsType; };
</sqf>


| [[BIS_fnc_error]] |See also=
|x5= <sqf>
// show error and abort if input is neither of type ARRAY nor array in format [SCALAR, ARRAY, <ANYTHING>, OBJECT]:
if !(_this isEqualTypeParams [0, [], nil, objNull]) exitWith { [_this, "isEqualTypeParams", [0, [], nil, objNull]] call BIS_fnc_errorParamsType; };
</sqf>
 
|seealso= [[BIS_fnc_error]]
}}
}}
[[Category:Function Group: Debug|{{uc:errorParamsType}}]]

Latest revision as of 15:06, 8 November 2023

Hover & click on the images for description

Description

Description:
Displays a parameter type error message (using BIS_fnc_error) explaining the problem.
Execution:
call
Groups:
Diagnostic

Syntax

Syntax:
[value, method, expected] call BIS_fnc_errorParamsType
Parameters:
value: Anything - (Optional, default nil) value received.
method: String - (Optional, default "") validation method, can be one of:
  • "isEqualType"
  • "isEqualTypeArray"
  • "isEqualTypeAll"
  • "isEqualTypeAny"
  • "isEqualTypeParams"
expected (Optional, default: nil): Anything - expected type.
Return Value:
Nothing

Examples

Example 1:
// show error and abort if input is not of type ARRAY: if !(_this isEqualType []) exitWith { [_this, "isEqualType", []] call BIS_fnc_errorParamsType; };
Example 2:
// show error and abort if array input is not in format [SCALAR, STRING, BOOL]: if !(_this isEqualTypeArray [0, "", true]) exitWith { [_this, "isEqualTypeArray", [0, "", true]] call BIS_fnc_errorParamsType; };
Example 3:
// show error and abort if array input is not in format [BOOL, BOOL, BOOL, ...]: if !(_this isEqualTypeAll true) exitWith { [_this, "isEqualTypeAll", true] call BIS_fnc_errorParamsType; };
Example 4:
// show error and abort if input is neither ARRAY nor OBJECT: if !(_this isEqualTypeAny [[], objNull]) exitWith { [_this, "isEqualTypeAny", [[], objNull]] call BIS_fnc_errorParamsType; };
Example 5:
// show error and abort if input is neither of type ARRAY nor array in format [SCALAR, ARRAY, <ANYTHING>, OBJECT]: if !(_this isEqualTypeParams [0, [], nil, objNull]) exitWith { [_this, "isEqualTypeParams", [0, [], nil, objNull]] call BIS_fnc_errorParamsType; };

Additional Information

See also:
BIS_fnc_error

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