Page tree
Skip to end of metadata
Go to start of metadata




Introduced in

Version:1.20

Description

Description:Loops through the passed array, and for each element, runs the code and sets the element to the result of the code. In the code, the contents of the current element being modified are stored in the variable _x, while the index of the element is stored in the variable _this. The array is modified by reference, and is also returned.

Syntax

Syntax:[array, condition] call fn_vbs_setEach
Parameters:
  • array: Array - The array.
  • condition: Code - The code to run.
Return Value:Array

Warning

When using functions in VBS versions older than 3.4, certain limitations and requirements should be kept in mind - the main ones being that capitalization of the function name is crucial, and that #include "\vbs2\headers\function_library.hpp" has to be included in every script that utilizes it. More Category VBS Scripting Functions.

Examples

Examples:
_array = array = [3,2,1]
[array, {_x+1}] call fn_vbs_setEach

array is now [4,3,2] 
_array =array = ["a","b","c"]

[array, {_this}] call fn_vbs_setEach

array is now [0,1,2] 

Additional Information

See also: fn vbs arrayInsert, fn vbs arrayAdd
Multiplayer: 
Problems: 

Notes