Page MenuHomeFeedback Tracker

New function BIS_fnc_getDeletedAndAdded
New, NormalPublic

Description

I'd like to propose a function i use pretty much in all interfaces with listboxes that need to be updated.
The purpose of this function is to know what have been added and deleted in an array.

Description: This function will parse reference and array to return added and deleted elements. The puspose of this function is to know what have been added and deleted in an array.
Syntax: [reference, array] call BIS_fnc_getDeletedAndAdded
Parameters: reference: Array - reference array

array: Array - updated array

Return Value: Array - in following format: [[deleted elements indexes], [added elements indexes]]

Details

Severity
None
Resolution
Open
Reproducibility
N/A
Operating System
Windows 11 x64
Operating System Version
23H2
Category
Scripting
Steps To Reproduce

Here is the code:

params ["_reference", "_array"];
private ["_toReturn"];

_toReturn = [[], []];
for [{ _i = 0 }, { _i < (count _reference) }, { _i = _i + 1 }] do {
	if((_array find (_reference select _i)) < 0) then {
		(_toReturn select 0) pushback _i; 
	};
};
for [{ _i = 0 }, { _i < (count _array) }, { _i = _i + 1 }] do {
	if((_reference find (_array select _i)) < 0) then {
		(_toReturn select 1) pushback _i; 
	};
};
_toReturn;

Event Timeline

XTankKiller updated the task description. (Show Details)Mon, Jun 17, 4:55 AM