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

[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,572
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