• 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] Looping code

Status
Not open for further replies.
Level 1
Joined
Jun 23, 2004
Messages
1
I'm having a hard time getting long loops to run properly in my maps, and I have been unable to find any information about this phenomenon on the Internet.

Code:
// This will run without problems
function ex1 takes nothing returns nothing
local integer i = 0 
    loop
        set i = i + 1

        if i == 5 then
            call DoNothing()
        endif 

         exitwhen i == 2000
     endloop
endfunction

// This will also run without problems
function ex2 takes nothing returns nothing
local integer i = 0 
    loop
        set i = i + 1

       // if i == 5 then
       //     call DoNothing()
       // endif 

         exitwhen i == 20000
     endloop
endfunction

// This function will never finish
function ex3 takes nothing returns nothing
local integer i = 0 
    loop
        set i = i + 1

        if i == 5 then
            call DoNothing()
        endif 

         exitwhen i == 20000
     endloop
endfunction

My question is: Why does ex3 hang/crash/break when the code is obviously correct? (This also goes for various nested loops when the number of iterations is too high). Any help would be greatly appreciated.
 
Level 2
Joined
Apr 13, 2004
Messages
29
There is a limit on the number of statements that a thread may execute without a wait. Once that limit is reached the thread is cancelled.
 
Status
Not open for further replies.
Top