• 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.

[vJASS] About "keyword".

Status
Not open for further replies.
Level 11
Joined
Oct 11, 2012
Messages
711
Hey guys, why the following does not work? Thanks a lot.
JASS:
scope example 
    keyword B
    //private keyword B does not work neither
    
    private function A takes nothing returns nothing
        local timer t = CreateTimer()
        call TimerStart(t,period,true,function B)
        set t = null
    endfunction
    
    private function B takes nothing returns nothing
        local timer t = GetExpiredTimer()
        .....
        set t = null
    endfunction
endscope
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
Your code will not work nevertheless, because this is vJass feature and in Jass you cannot reference functions that are defined below your function, so even if

JASS:
keyword B

function A takes nothing returns nothing
    call B.execute()
endfunction

function B takes nothing returns nothing
endfunction

works, if you put TimerStart, or Condition or anything that takes code as parameter into function A, you cannot make it work and you will have to move the function above A
 
Level 11
Joined
Oct 11, 2012
Messages
711
Your code will not work nevertheless, because this is vJass feature and in Jass you cannot reference functions that are defined below your function, so even if

JASS:
keyword B

function A takes nothing returns nothing
    call B.execute()
endfunction

function B takes nothing returns nothing
endfunction

works, if you put TimerStart, or Condition or anything that takes code as parameter into function A, you cannot make it work and you will have to move the function above A

Got it, thnx, +Rep
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
JASS:
scope example initializer init
    globals
        private code B_CODE
    endglobals
    
    private function A takes nothing returns nothing
        local timer t = CreateTimer()
        call TimerStart(t,period,true,B_CODE)
        set t = null
    endfunction
    
    private function B takes nothing returns nothing
        local timer t = GetExpiredTimer()
        .....
        set t = null
    endfunction

    private function init takes nothing returns nothing
        set B_CODE = function B
    endfunction
endscope
 
Level 11
Joined
Oct 11, 2012
Messages
711
JASS:
scope example initializer init
    globals
        private code B_CODE
    endglobals
    
    private function A takes nothing returns nothing
        local timer t = CreateTimer()
        call TimerStart(t,period,true,B_CODE)
        set t = null
    endfunction
    
    private function B takes nothing returns nothing
        local timer t = GetExpiredTimer()
        .....
        set t = null
    endfunction

    private function init takes nothing returns nothing
        set B_CODE = function B
    endfunction
endscope

Beautiful, +Rep!
 
Status
Not open for further replies.
Top