What does array size mean?

Level 4
Joined
Jul 22, 2010
Messages
74
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 :D
 
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.
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
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.
 
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.
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
@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.
 
Level 25
Joined
Aug 18, 2009
Messages
4,087
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 62
Joined
Jan 18, 2005
Messages
27,041
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).
 
Top