Results 1 to 10 of 10

Thread: do.. while?

  1. #1

    do.. while?

    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.

  2. #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)

  3. #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"


  4. #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.

  5. #5
    Admiral of Awesome
    Posts
    18,423
    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).]

  6. #6
    Yes, so what... all I wanna know is if they work.
    Dreams of a dreamer from afar to a fardreamer.

  7. #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)

  8. #8
    Registered User
    Posts
    607
    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

  9. #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.

  10. #10
    Registered User
    Posts
    607
    That way you get your answer the fastest, than taking the time to ask around and wait for some guy that actually knows

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •