• 🏆 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] 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