Used by every experiment

JASS:
function H2I takes handle h return integer
return h
return 0
endfunction
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
set gg_trg_Untitled_Trigger_001 = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Untitled_Trigger_001, 1.00 )
call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction
Everything in a World Editor trigger called Untitled Trigger
Table:
|
Script | Result |
 JASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
local location loc=Location(0,1)
call BJDebugMsg(I2S(H2I(loc)))
call RemoveLocation(loc)
endfunction
|
Shows a different number every time (keeps incrementing it)
|
 JASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
local location loc=Location(0,1)
call BJDebugMsg(I2S(H2I(loc)))
call RemoveLocation(loc)
set loc=null
endfunction
|
Shows the same number every time.
|
 JASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
set udg_loc=Location(0,1)
call BJDebugMsg(I2S(H2I(udg_loc)))
call RemoveLocation(udg_loc)
endfunction
|
Shows 2 numbers (alternates them)
|
 JASS:
function LaLoc takes location loc return nothing
call BJDebugMsg(I2S(H2I(loc)))
call RemoveLocation(loc)
endfunction
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
call LaLoc(Location(0,1))
endfunction
|
Shows the same number every time.
|
Conclusions
The same as always , local variables of handle derived types need to be set to null before the function ends.
edit note: a small variation of the first 2 experiments using a local array had the same result:
Table:
 JASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
local location array loc
set loc[0]=Location(0,1)
call BJDebugMsg(I2S(H2I(loc[0])))
call RemoveLocation(loc[0])
endfunction
|
 JASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
local location array loc
set loc[0]=Location(0,1)
call BJDebugMsg(I2S(H2I(loc[0])))
call RemoveLocation(loc[0])
set loc[0]=null
endfunction
|
Shows different, incrementing numbers
|
Shows the same number everytime
|