HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Experiments (JASS)

02-25-2006, 07:03 PM#1
Vexorian
Used by every experiment
Collapse JASS:
//At the top:

//===========================================================
// H2I:
//     If you don't understand what this function is you
//  know zero about JASS and how to use it.
//
function H2I takes handle h return integer
   return h
   return 0
endfunction

//In the bottom:

//===========================================================================
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:
ScriptResult
Collapse 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)
Collapse 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.
Collapse 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)
Collapse 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:
Collapse 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
Collapse 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