PDA

View Full Version : do.. while?



Fardreamer
10-14-2000, 06:30 AM
Does a do..while loop work in cogscript? (It's the equivelent of the repeat..until loop in Pascal).

zagibu
10-14-2000, 11:22 AM
never tried...simple while loops work, so i think a do...while will also. Try it...

Obsidian
10-16-2000, 02:04 PM
Yes while loops work in Cog.

While(arugment)
{
<stuff>
}

-Obsidian

------------------
"Beauty is only skin deep, but uglyness goes right to the bone"

Fardreamer
10-17-2000, 05:07 AM
Not while loops, do..while loops (from the C language).

do
{
<command block>
}
while (<boolean expression> );

Assuming Cog is based on C, do..while should work.

Jon`C
10-17-2000, 05:17 AM
Those were kinda rendered obsolete by the while(argument) loop (except that the command block is always executed at least once). Don't forget, arguments in C/C++ are always treated as boolean.

[This message has been edited by Jon`C (edited October 17, 2000).]

Fardreamer
10-17-2000, 09:54 AM
Yes, so what... all I wanna know is if they work. http://forums.massassi.net/html/wink.gif

zagibu
10-18-2000, 06:54 AM
you could also achieve the same loop with this:

do all commands;
while(condition)
{
do all commands;
}

thats the same...one execution, then conditioncheck...

Hideki
10-18-2000, 11:01 AM
Well, if it doesn't mean to know if it works or not, because the "while" does just about the same, except it only doesn't go through any if it's false,(and you can overcome with a variable or something), then why not just run the script once in JK?

------------------
http://millennium.massassi.net/ - Millennium

Fardreamer
10-19-2000, 05:56 AM
THe only difference it'll make in my cog is that I won't have to give a value to the condition variable before I start the loop. No big deal, but it looks better code-wise...

Anyway I was just curious to know. I guess I'll just have to try it myself, eh?

Hideki
10-20-2000, 12:01 PM
That way you get your answer the fastest, than taking the time to ask around and wait for some guy that actually knows http://forums.massassi.net/html/wink.gif

------------------
http://millennium.massassi.net/ - Millennium