HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Do loops stop codes?

09-26-2006, 11:15 AM#1
darkwulfv
When a code is being read, does it stop at loops, perform the loop until it ends, then continue through the rest? Or does it activate the loop (which continues to run) and go on through the rest of the code?
I need to know this for my code, because if it is the first, then I can put my finishing lines at the end, but if its the second, I'll have to run a check, and then do the finishing lines.
Thanks!
~Darkwulfv
(a little over 500 posts. w00t)
09-26-2006, 11:53 AM#2
AnachroNia
Have you ever programed in a programing language like C, PHP or something like this? This is structured programing. This programs CAN NOT do more than one thing in one moment - if you have a loop (for example a FOR cycle) It first executes the whole loop and then go through the other code.
09-26-2006, 11:59 AM#3
sheep.spirit
yes, loops stop the code, or else why do you need them? If u want to execute together, then use a timer fucntion instead
09-26-2006, 02:58 PM#4
The)TideHunter(
Test it.

Collapse JASS:
function Test takes nothing returns nothing
    local integer i = 0
    loop
        exitwhen i==50
        call TriggerSleepAction(0.1)
        set i = i + 1
    endloop
    call BJDebugMsg("Loop Finished")
endfunction

It should wait rougly 5 seconds, then it will say Loop Finished.
So yes, loop makes it wait.
09-26-2006, 07:21 PM#5
darkwulfv
Ok, thats all I was wondering. Thanks!