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

Can Functions take Variables/Arrays?

Status
Not open for further replies.
You can't take in an array. You can input an array element, but not the array itself.

For example:
JASS:
function Test takes integer i returns nothing

endufnction

globals
    integer array z
endglobals

call Test(z) // won't work
call Test(z[0]) // works

Passing an array is possible in some programming languages, e.g. Java, but not in JASS.

Also, you should post JASS questions in the Triggers & Scripts forum. Moved.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
You can however pass a struct instance with array (or not) members inside the struct.

Or a dynamic array but that's basically the same thing limited to one variable only.

Read the jasshelper documentation and check the generated jass code to understand how it works (and the limitations).
 
Status
Not open for further replies.
Top