HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

passing local variables from function to function

03-20-2004, 05:52 AM#1
jardragon901
Can someone help me, I have been trying to pass my local unit variable "hero" from one function to the next function, how would I do this without using globals?
03-20-2004, 07:09 AM#2
KaTTaNa
Depends on how you are calling the function.
If it is a normal call, you do like this:
Code:
function Foo takes integer a returns nothing
    // Do something with the local integer 'a'
endfunction
function Bar takes nothing returns nothing
    local integer a = 15
    call Foo(a) // Pass it as a parameter
endfunction

However, if you are using it as a callback in a ForGroup for example, you cannot use parameters.
In that case you must either use globals or the gamecache.
03-20-2004, 08:59 AM#3
jardragon901
Quote:
Originally Posted by KaTTaNa
Depends on how you are calling the function.
If it is a normal call, you do like this:
Code:
function Foo takes integer a returns nothing
    // Do something with the local integer 'a'
endfunction
function Bar takes nothing returns nothing
    local integer a = 15
    call Foo(a) // Pass it as a parameter
endfunction

However, if you are using it as a callback in a ForGroup for example, you cannot use parameters.
In that case you must either use globals or the gamecache.
Thank you so much, that was a big help :D .