Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → do.. while?
do.. while?
2000-10-14, 4:30 AM #1
Does a do..while loop work in cogscript? (It's the equivelent of the repeat..until loop in Pascal).
Dreams of a dreamer from afar to a fardreamer.
2000-10-14, 9:22 AM #2
never tried...simple while loops work, so i think a do...while will also. Try it...
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2000-10-16, 12:04 PM #3
Yes while loops work in Cog.

While(arugment)
{
<stuff>
}

-Obsidian

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

2000-10-17, 3:07 AM #4
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.
Dreams of a dreamer from afar to a fardreamer.
2000-10-17, 3:17 AM #5
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).]
2000-10-17, 7:54 AM #6
Yes, so what... all I wanna know is if they work. [http://forums.massassi.net/html/wink.gif]
Dreams of a dreamer from afar to a fardreamer.
2000-10-18, 4:54 AM #7
you could also achieve the same loop with this:

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

thats the same...one execution, then conditioncheck...
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2000-10-18, 9:01 AM #8
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
2000-10-19, 3:56 AM #9
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?
Dreams of a dreamer from afar to a fardreamer.
2000-10-20, 10:01 AM #10
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

↑ Up to the top!