• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] I'm learning JASS, please help me to fix this easy function!

Status
Not open for further replies.
Level 31
Joined
Apr 17, 2009
Messages
3,571
I was trying to make the exercise of a tutorial and I got some compiling errors. Ignore the use/sense of this function.
I'm just curious about the syntax.

JASS:
function DivideNumbers takes integer n returns nothing
    local integer dividant = 1
    local integer array result
    local integer array1 = 1
    loop
          set result [array1] = n/dividant
          set dividant = dividant+1 
          set array1 = array1 +1
          exitwhen dividant == n
    endloop
    call BJDebugMsg(result [array1])

endfunction

I get an error at this:

JASS:
set dividant = dividant+1


Can you tell what's wrong?
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
There should be nothing wrong with that line.

I'm guessing you got the error because you put a space between the brackets and result. Ex: Should be result[array1] The strange thing is that I didn't get any error from that. (I'm using JNGP)

The error that I got was from your code came from your debug message because you're putting an integer instead of a string.
It should be call BJDebugMsg(I2S( result[array1] )). I2S converts the integer to a string.
 
Status
Not open for further replies.
Top