• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] array initialization

Status
Not open for further replies.

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
Hi,

i have a problem,
i want to store temporarilty some unit into an array, and use the unit[x] inside the trigger.
i won't need it outside the trigger so i want to make it local.
local unit is ok but how to declare a local unit array?
unit[0]
unit[1]
etc...
will it work if i use a loop to fill the local unit[] with data?
because there is no way to specify the size of the array and initialize it...
i don't know in advance how many units i will store in it.
 

ABM

ABM

Level 7
Joined
Jul 13, 2005
Messages
279
thanks i had problems because i tried to use
local unit array name[]
actually i didn't need the []
only need them later when store things...

but another problem after i don't need anymore the data how do i clean all the array data?
[Jass=]
local integer count
local unit array unitz

set count = count + 1
set unitz[count] = u (a unit variable)
do things with unitz

//cleaning
set i = 1
loop
exitwhen i > count
set unitz=null
set i = i +1
endloop
[/code]
is it ok like this?
 
Status
Not open for further replies.
Top