[JASS] Simple question about locals.....

Status
Not open for further replies.
Level 9
Joined
Oct 11, 2009
Messages
477
I have a question, why do I get an error that reads "expected a name" in a trigger where I used the local but on the first trigger it works.


In other words, is it possible to retrieve a data of a local variable without using global variables in between two or more than a trigger?
 
I have a question, why do I get an error that reads "expected a name" in a trigger where I used the local but on the first trigger it works.


In other words, is it possible to retrieve a data of a local variable without using global variables in between two or more than a trigger?

You can't. You have to resort to hashtables/globals. Local variables are local to the function. =)
 
JASS:
globals
    private real tempReal
endglobals

function ExampleChild takes nothing returns nothing
    if(tempReal>0) then
        call DoNothing()
    endif
endfunction

function Example takes nothing returns nothing
    set tempReal=3
    call ExampleChild()
endfunction

Remember, the above code is the same thing as:

JASS:
function ExampleChild takes real r returns nothing
    if(r>0) then
        call DoNothing()
    endif
endfunction

function Example takes nothing returns nothing
    call ExampleChild(3)
endfunction

You can use global variables to "transfer" data between functions that are executed sequentially because only one thread runs at a time. This is useful for certain things that do not allow parameters, such as group enumerations. Just so you know.
 
Status
Not open for further replies.
Back
Top