[Jass 101] - Statements & Structure

Jass Tutorials

Remembering the previous tutorial we were ready to start coding. In fact we revealed what's inside those GUI blocks ans we saw they were just functions. Now it's time to understand the structure and how we should write.

When the code in the map is armed in the *.j file, it will condense the code in this way:

Code (jass) Select
//Global section
globals

   //here you'll find all the global variables in the map

endglobals
//End of the Global section

//Function section: here you will find all the functions that will manage the map.
//...

function bla1 takes ... returns ...
   // here will be a bunch of functions
endfunction

function bla2 takes ... returns ...
   // and more functions... :D
endfunction

//... and more functions ... :)

function main takes nothing returns nothing
   // Here's the main initial function
endfunction


In JASS the function's order is very important in the sense that any function required by another function must be over the caller one. Here's an example:

[btable]Incorrect[c]Correct[r]
Code (jass) Select
function Caller takes nothing returns nothing
    // some code...
    call Called()
    // More code...
endfunction

function Called takes nothing returns nothing
    // Do some stuff...
endfunction
[c]
Code (jass) Select
function Called takes nothing returns nothing
    // Do some stuff...
endfunction

function Caller takes nothing returns nothing
    // some code...
    call Called()
    // More code...
endfunction
[/btable]

to be continued...
Awww, please teach us more on the next tutorial. Or maybe me? lol
I'm on it... this weekend I'll continue with this part.