Page MenuHomeFeedback Tracker

[BIS functions] getVariables in Support Module (+other) functions don't have a default value, causing errors
Assigned, NormalPublic

Description

For example, line 17 of refreshMainWindow.sqf (in modules_f.pbo\supports\procedures) is:

       {
		_total = 0;
		_type = _x;
		{
			_total = _total + (_x getVariable format ["BIS_SUPP_limit_%1", _type])
		} forEach _requesterModules;
		player setVariable [format ["BIS_SUPP_limit_%1_total", _type], _total]
	} forEach [
		"Artillery",
		"CAS_Heli",
		"CAS_Bombing",
		"UAV",
		"Drop",
		"Transport"
	];

when one creates the "SupportRequester" module, they also have to define all of these variables, otherwise the function will throw an error.

We can use the alternative syntax of getVariable to fix this issue.

For example, the issues with the above case can be fixed using this regex:
find: (this regex can also account for most cases of getVariable format ... )

getVariable *([^[ ](.(?!getVariable))*BIS_SUPP_limit.*?(((?<!\[)["'](?!,))|(\])))

replace:

getVariable \[\1, 0\]

This fixes the above issue (must be used on all scripts in modules_f.pbo\supports)

The additional details provides a sample regex to find all getVariables not using the alternative syntax, if you want to fix them all. (although the default value for them can be different than 0)

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 7
Category
Scripting
Additional Information

regex to find (almost) all getVariables not using the alternative syntax:

getVariable *([^[ ].*?(((?<!\[)["'](?!,))|(\])))

Event Timeline

Leopard20 created this task.Nov 7 2020, 2:17 PM
Leopard20 added a subscriber: BIS_fnc_KK.
This comment was removed by Leopard20.
Leopard20 updated the task description. (Show Details)Nov 7 2020, 2:46 PM
Leopard20 updated the task description. (Show Details)Nov 7 2020, 3:01 PM
BIS_fnc_KK changed the task status from New to Assigned.
Leopard20 updated the task description. (Show Details)Nov 7 2020, 5:45 PM
Leopard20 edited Additional Information. (Show Details)