# What does array size mean?

Status
Not open for further replies.

#### cr4ck4r

Level 4
I have got a question.
I somehow got self confused ..<.<

example
integer [array]

if i set a array in GUI, what means the "SIZE" of the array, what if it is set to 1, what if it set to 500 or even 8191?
i dont understand the "size"..

if it is =1

i still can integer [>1]

integer [1]
integer [232]
integer [4353]

...
explains to me ..please

#### Pharaoh_

Level 40
Each array is actually a channel that generates a unique identity for the entity you set into the variable. An array can maximum store 8191 data into that specific variable.
So, if Integer[1] = 10 and Integer[2] = 15, Integer[1] != Integer[2].
Additionally, Unit[1] = (Last created unit) and Unit[2] = (Triggering unit) are not the same; they share the same variable but each array slot represents a different value.

#### Garfield1337

Level 20
Pharaoh_, you didn't understand what he asked - he meant the size in variable editor.
Well, as far as i know, the size represents the number to which the array members are initialized. If the size is, for example, 5, the variables with indexes from 0 to 5 will be initialized.
In GUI, this doesn't really matter so just keep it at 1.

#### Pharaoh_

Level 40
Yes, I was just going to edit it. A useful explanation is this:
In global arrays, what does the "size" mean?
The size is how many layers the array has. The total number of data items able to be stored in a global array is "size+1". This is due to layer 0 counting as a valid storage location. If you want to store 1 data item per player for 12 players in a single global variable, then an array size of 11 is needed.
from http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/array-tutorial-17789/, kinda what Garfield1337 said.

#### Chewii

Level 11
How come if i make and variable with size 1, And then uses it for my unit, Unit[1] but it will also work if i make another Unit and name it to Unit[2]

#### Garfield1337

Level 20
@Pharaoh_
That quote isn't really true because it defies what the OP said.
The size is a number to which all array members with indexes from 0 to size are given 'initial value' (found in variable editor).
You can use any variable with index from 0 to 8190 except that all variables with index above the size will have null value.

#### WaterKnight

Level 26
The tutorial suggests that when you set size to 1, you could not use index 10 for example, which is wrong. Like Garfield1337 said, the array is initialized from 0 to size with the preset value. But it matters in GUI because it is a GUI functionality and in Jass you can write it yourself. Where it would make a difference in GUI, is, you cannot create certain objects there like timers, they can only be created as a preset in a variable. So setting the size would equip the array with valid timers, allowing you to use them.

#### Dr Super Good

Spell Reviewer
Level 64
JASS arrays are dynamic arrays with a maximum size of 2^13. In GUI, the size field is used to initialize every index to a value (as some types need an object to work). Be aware that the array initialization that GUI uses can cause the op limit to be reached and thus a thread crash (breaking all triggers after that point).

Status
Not open for further replies.

Replies
5
Views
874
Replies
1
Views
704
Replies
18
Views
2K
Replies
4
Views
1K
Replies
6
Views
902