View Poll Results: How many time beep() will be preformed?

Voters
21. You may not vote on this poll
  • 0 times.

    18 85.71%
  • 1 time.

    1 4.76%
  • It really all depends on the weather outside.

    2 9.52%
Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: For loops

  1. #1

    For loops

    [pascal]For I:= 0 to –1 do beep();[/pascal]
    How many time beep() will be preformed?
    [size=9px]BEGIN GEEK CODE BLOCK
    <br />d s-- : a24 GB GCS GTW GE C++ P L+ W++ N+ K- w++++ M- PS+ PE+ Y- t+ 5+++ X+ R*
    <br />tv b+ DI++ D+ e++ h+ G-
    <br />END GEEK CODE BLOCK[/size]
    <br />Create your own GeekCode block at: <a href="">...</a>

  2. #2

    For loops

    :lol:
    what kind of test is that? :lol:
    Will: &quot;Before you learn how to cook a fish you must first learn how to catch a fish.&quot; coolest

  3. #3

    For loops

    I really don't understand if this would be a trick or something... :? :lol:
    <center>
    <br />Federico &quot;FNX&quot; Nisoli
    <br />Lead Programmer - FNX Games
    <br />http://www.fnxgames.com
    <br /><img src="http://www.fnxgames.com/imgs/banners/fnxban.gif">
    <br /></center>

  4. #4

    For loops

    In the former version of my script language the answer would have been 1
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  5. #5

    For loops

    0. Because once you click compile, Delphi, and even Freepascal, would beat you over the head with a very large hammer.

  6. #6

    For loops

    probably 0 times, unless the overflow checking is OFF, in that case it will go around and beep 4294967295 times.
    This is my game project - Top Down City:
    http://www.pascalgamedevelopment.com...y-Topic-Reboot

    My OpenAL audio wrapper with Intelligent Source Manager to use unlimited:
    http://www.pascalgamedevelopment.com...source+manager

  7. #7

    For loops

    zero times, surely!?

    I routinely use this sort of code:


    Code:
    For I &#58;= 0 to high&#40;GameObjects&#41; do something;
    And if high(GameObjects) returns -1, as it does when the program is first run, it just skips the for loop.
    My site: DelphiTuts.com (coming soon)...

    Download Font Studio 4.21 here.

  8. #8
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    For loops

    Well technically if there is a thunderstorm outside and your computer is right beside the window and a bolt of lightning hits your computer case and zaps the guts of it right as you hit F9, it could possibly end up doing a single beep as it powers down it's newly fried circuits.
    Jason McMillen
    Pascal Game Development
    Co-Founder





  9. #9

    For loops

    The reason I asked this is because I had a similar code to that (only difference was that -1 was a var) that compiled and ran as 90% expected (if the var was –1 it didn’t enter the loop) using Delphi6.
    Few weeks ago I needed to add a few features to that application and I decided to do it with Delphi2006. The new futures I added worked fine but accompanied with it was a strange new bug..

    Long story short, after several hours of debugging I found the problem with the for loop. It wasthe exact same code that worked fine in Delphi6, but in Delphi2006 I had to add an If statement before the loop!

    It’s the first time I encountered this kind of behavior with for loops.. but hey, I’ve seen worse :?
    [size=9px]BEGIN GEEK CODE BLOCK
    <br />d s-- : a24 GB GCS GTW GE C++ P L+ W++ N+ K- w++++ M- PS+ PE+ Y- t+ 5+++ X+ R*
    <br />tv b+ DI++ D+ e++ h+ G-
    <br />END GEEK CODE BLOCK[/size]
    <br />Create your own GeekCode block at: <a href="">...</a>

  10. #10
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    For loops

    The most common case I've seen for needing an if statement before a for loop was when you are accessing object classes within that loop that may not have it's first element created so you'll get a memory error because the class was not pointing to memory that was allocated.

    Other than that I don't see much reason to use an if statement as I've come to understand the language. Maybe avoid triggering an over anxious debugger?
    Jason McMillen
    Pascal Game Development
    Co-Founder





Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

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