Making a loop hesitate.

Discussion in 'Java' started by snewcrash, Dec 3, 2005.

  1. snewcrash

    snewcrash Guest

    I'm new to java so sorry if this is a stupid question. I have a program
    where I have 360 lines output. I need the screen to pause each time it
    fills up. So far I made a for statement for lines 1-20, 20-45, etc. How
    do I get the screen to pause at the end of each for statement? I've
    been looking at Thread.sleep, but I'm unsure how to use it in my
    program. This is what I have so far:

    http://pastebin.com/447592
     
    snewcrash, Dec 3, 2005
    #1
    1. Advertising

  2. snewcrash

    Roedy Green Guest

    On 3 Dec 2005 12:39:28 -0800, "snewcrash" <>
    wrote, quoted or indirectly quoted someone who said :

    >I'm new to java so sorry if this is a stupid question. I have a program
    >where I have 360 lines output. I need the screen to pause each time it
    >fills up.


    see http://mindprod.com/jgloss/console.html

    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Dec 3, 2005
    #2
    1. Advertising

  3. snewcrash

    snewcrash Guest

    I looked there, and I'm not exactly sure what you're trying to point
    out....
     
    snewcrash, Dec 3, 2005
    #3
  4. snewcrash

    Chris Smith Guest

    snewcrash <> wrote:
    > I'm new to java so sorry if this is a stupid question. I have a program
    > where I have 360 lines output. I need the screen to pause each time it
    > fills up. So far I made a for statement for lines 1-20, 20-45, etc. How
    > do I get the screen to pause at the end of each for statement? I've
    > been looking at Thread.sleep, but I'm unsure how to use it in my
    > program.


    Easy:

    try
    {
    Thread.sleep(500);
    } catch (InterruptedException e) { }

    --
    www.designacourse.com
    The Easiest Way To Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
     
    Chris Smith, Dec 3, 2005
    #4
  5. snewcrash

    snewcrash Guest

    PERFECT! Just what I was looking for, thanks a lot. =)
     
    snewcrash, Dec 3, 2005
    #5
  6. snewcrash

    snewcrash Guest

    Ok, so I made separate for statements to block off each section of
    output. Is there a way to do this without having all these for
    statements?

    My code: http://pastebin.com/447685
     
    snewcrash, Dec 3, 2005
    #6
  7. snewcrash

    Guest

    wouldn't a simple comparison of the counter work for u ? something like
    ....

    for(counter =0 ; counter <....) {
    //do ur stuff
    if (counter == 20 || counter ==44 ....) {
    Thread.sleep(....)
    }
    }
     
    , Dec 3, 2005
    #7
  8. snewcrash

    VisionSet Guest

    <> wrote in message
    news:...
    > wouldn't a simple comparison of the counter work for u ? something like
    > ...
    >
    > for(counter =0 ; counter <....) {
    > //do ur stuff



    if (counter % 20 == 0){


    > Thread.sleep(....)
    > }
    > }
    >


    --
    Mike W
     
    VisionSet, Dec 3, 2005
    #8
  9. snewcrash

    snewcrash Guest

    just what i was looking for. thanks for everyones help.
     
    snewcrash, Dec 4, 2005
    #9
  10. On 2005-12-03, snewcrash penned:
    > I'm new to java so sorry if this is a stupid question. I have a
    > program where I have 360 lines output. I need the screen to pause
    > each time it fills up. So far I made a for statement for lines 1-20,
    > 20-45, etc. How do I get the screen to pause at the end of each for
    > statement? I've been looking at Thread.sleep, but I'm unsure how to
    > use it in my program. This is what I have so far:
    >
    > http://pastebin.com/447592


    I don't know your ultimate goal, but wouldn't it be better to wait on
    user input every 20 lines or so?

    asdfa
    asdfa
    fasafda
    Press <Enter> to continue ...

    That way, the user gets to decide how much time they need to digest
    the data ...

    --
    monique

    Ask smart questions, get good answers:
    http://www.catb.org/~esr/faqs/smart-questions.html
     
    Monique Y. Mudama, Dec 5, 2005
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VGltOjouLg==?=

    Loop the loop...

    =?Utf-8?B?VGltOjouLg==?=, Feb 16, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    1,385
    Karl Seguin
    Feb 16, 2005
  2. Replies:
    5
    Views:
    1,877
    Andrew Thompson
    Jan 12, 2005
  3. Steven

    while loop in a while loop

    Steven, Mar 24, 2005, in forum: Java
    Replies:
    5
    Views:
    2,238
    Tim Slattery
    Mar 30, 2005
  4. Replies:
    1
    Views:
    127
    Vincent van Beveren
    Jul 6, 2006
  5. Isaac Won
    Replies:
    9
    Views:
    382
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page