Page MenuHomeFeedback Tracker

param is working but throwing errors when defaults are used in most cases
New, WishlistPublic

Description

Basically if you use param and give it a data type its not expecting it still returns the default value but also throws an rpt error. I can understand why the error would be thrown but is this intentional as it did not behave like this in 1.52?

Due to this change param is not as useful as it once was. If this is an intentional change and not a bug we are going to have to look at other alternatives.

Details

Legacy ID
1360642921
Severity
None
Resolution
Open
Reproducibility
Always
Category
Scripting
Steps To Reproduce

0 spawn {EP = {RESULT = _this param [0,[],[[]]] }; [""] call EP;};
// RESULT = [];
throws error:
Error Type String, expected Array

0 spawn {EP = {RESULT = _this param [0,5,[5]] }; [""] call EP;};
// RESULT = 5
throws error:
Error Type String, expected Number

0 spawn {EP = {RESULT = _this param [0,5,[5]] }; [] call EP;};
// RESULT = 5
No Error

0 spawn {EP = {RESULT = _this param [0,5,[5]] }; call EP;};
// RESULT = 0
No Error - looks like _this from spawn was passed to the EP function hence the 0 result.

0 spawn {EP = {RESULT = _this param [0,[],[[]]] }; 2 call EP;};
// RESULT = [2]
No Error as expected

0 spawn {EP = {RESULT = _this param [0,"",[""]] }; 2 call EP;};
// RESULT = ""
Error Type Array, expected String

0 spawn {EP = {RESULT = _this param [0,"",[""]] }; [] call EP;};
// RESULT = ""
No Error

0 spawn {EP = {RESULT = _this param [0,"",[""]] }; call EP;};
// RESULT = ""
Error Type Number, expected String

0 spawn {EP = {RESULT = _this param [0,"",[""]] }; [5] call EP;};
// RESULT = ""
Error Type Number, expected String

Additional Information

-Code is spawned just to rule out any debug console issues with param.

Event Timeline

vbawol edited Steps To Reproduce. (Show Details)Dec 11 2015, 3:51 PM
vbawol edited Additional Information. (Show Details)
vbawol set Category to Scripting.
vbawol set Reproducibility to Always.
vbawol set Severity to None.
vbawol set Resolution to Open.
vbawol set Legacy ID to 1360642921.May 8 2016, 1:18 PM
commy2 added a subscriber: commy2.May 8 2016, 1:18 PM

This was done intentionally. The same happens with paramS.

"Since Arma 3 v1.53.132691, onscreen errors are displayed for when the input is of the wrong type or size."

See: https://community.bistudio.com/wiki/param

The alternative is to use the isEqualType familiy of commands.

https://community.bistudio.com/wiki/isEqualType

vbawol added a subscriber: vbawol.May 8 2016, 1:18 PM

Thanks, I see the note on the wiki now. It makes sense but would have been nice to keep it down to only one command vs three. Basically if there is any chance that a function will get invalid data you should not use param(s) anymore as it will work but throw errors.

This is what I came up with, for now:
_data = [];
_newData = _this select 0;
if (_newData isEqualType _data) then {

_data = _newData;

};

raymix added a subscriber: raymix.May 8 2016, 1:18 PM

I thought the whole purpose of param/params was to get rid off these errors in case of a wrong input. That alone made them one of the strongest commands I've had pleasure working with.

Now they are pretty much useless.

For those who are looking for alternatives - use BIS_fnc_param, it is slower than it's binary cousin, but will not give you errors.

@vbawol

params "_value", 13;

if !(_value isEqualType 0) then {

_value = 13;

};

rgr that commy2 that is a bit smaller but that is still 3 commands and 2 more commands than we should need to accomplish this task.

BI devs, if this is not subject to change please close the issue. Otherwise could you please look into adding a way to at least suppress the errors so we can use param(s) as it was originally implemented?