Wait, pause, sleep, w/e

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • 3than7

    Wait, pause, sleep, w/e

    Im in the video club at my school, and for a presentation were making,
    we need some computer scenes.

    Each of the characters has an ID wich i have used as an IF function so
    typing the right id # goes to the specified character. For the next
    part, i have a bunch of text that makes little sene but sounds
    "computery" to a non comupter literate person. Basically connecting,
    database, and mainframe thrown around, if u can understand that.
    For the connecting part, i would like to make the word connecting
    appear ( using cout<<"connecti ng\n"; ) For the next part, . . . how
    do i make the periods come onto the screen once every say, 2 seconds so
    it looks like its actually loading something.
    Rember, this isnt a purposeful program, its intended to look computery,
    and thats about all

    thanks for any help,,, ~3than

  • Mike Wahler

    #2
    Re: Wait, pause, sleep, w/e


    "3than7" <elodics@gmail. comwrote in message
    news:1166497301 .056595.240590@ l12g2000cwl.goo glegroups.com.. .
    Im in the video club at my school, and for a presentation were making,
    we need some computer scenes.
    >
    Each of the characters has an ID wich i have used as an IF function so
    typing the right id # goes to the specified character. For the next
    part, i have a bunch of text that makes little sene but sounds
    "computery" to a non comupter literate person. Basically connecting,
    database, and mainframe thrown around, if u can understand that.
    For the connecting part, i would like to make the word connecting
    appear ( using cout<<"connecti ng\n"; ) For the next part, . . . how
    do i make the periods come onto the screen once every say, 2 seconds so
    it looks like its actually loading something.
    Rember, this isnt a purposeful program, its intended to look computery,
    and thats about all
    >
    thanks for any help,,, ~3than

    #include <ios>
    #include <iostream>
    #include <ctime>
    #include <string>

    void status (const std::string text,
    unsigned int duration,
    unsigned int interval)
    {
    std::cout << text;
    std::time_t last;
    std::time_t begin(std::time (0));

    while(std::diff time(last = std::time(0), begin) < duration)
    {
    while(std::diff time(std::time( 0), last) < interval)
    ; /* empty statement */

    std::cout << '.' << std::flush;
    }
    }

    int main()
    {
    status("connect ing", 10, 2);
    std::cout << " Done.\n";
    return 0;
    }


    -Mike


    Comment

    • 3than7

      #3
      Re: Wait, pause, sleep, w/e


      Mike Wahler wrote:
      "3than7" <elodics@gmail. comwrote in message
      news:1166497301 .056595.240590@ l12g2000cwl.goo glegroups.com.. .
      Im in the video club at my school, and for a presentation were making,
      we need some computer scenes.

      Each of the characters has an ID wich i have used as an IF function so
      typing the right id # goes to the specified character. For the next
      part, i have a bunch of text that makes little sene but sounds
      "computery" to a non comupter literate person. Basically connecting,
      database, and mainframe thrown around, if u can understand that.
      For the connecting part, i would like to make the word connecting
      appear ( using cout<<"connecti ng\n"; ) For the next part, . . . how
      do i make the periods come onto the screen once every say, 2 seconds so
      it looks like its actually loading something.
      Rember, this isnt a purposeful program, its intended to look computery,
      and thats about all

      thanks for any help,,, ~3than
      >
      >
      #include <ios>
      #include <iostream>
      #include <ctime>
      #include <string>
      >
      void status (const std::string text,
      unsigned int duration,
      unsigned int interval)
      {
      std::cout << text;
      std::time_t last;
      std::time_t begin(std::time (0));
      >
      while(std::diff time(last = std::time(0), begin) < duration)
      {
      while(std::diff time(std::time( 0), last) < interval)
      ; /* empty statement */
      >
      std::cout << '.' << std::flush;
      }
      }
      >
      int main()
      {
      status("connect ing", 10, 2);
      std::cout << " Done.\n";
      return 0;
      }
      >
      >
      -Mike

      Thank you very much, but is this the simpilist way to do this, because
      i'd like to be able to use this feature elsewhere, and im not sure
      exactly what you did there. Thanks ALOT thou, very helpfull.

      Comment

      • Alan Johnson

        #4
        Re: Wait, pause, sleep, w/e

        3than7 wrote:
        Mike Wahler wrote:
        >"3than7" <elodics@gmail. comwrote in message
        >news:116649730 1.056595.240590 @l12g2000cwl.go oglegroups.com. ..
        >>Im in the video club at my school, and for a presentation were making,
        >>we need some computer scenes.
        >>>
        >>Each of the characters has an ID wich i have used as an IF function so
        >>typing the right id # goes to the specified character. For the next
        >>part, i have a bunch of text that makes little sene but sounds
        >>"computery" to a non comupter literate person. Basically connecting,
        >>database, and mainframe thrown around, if u can understand that.
        >>For the connecting part, i would like to make the word connecting
        >>appear ( using cout<<"connecti ng\n"; ) For the next part, . . . how
        >>do i make the periods come onto the screen once every say, 2 seconds so
        >>it looks like its actually loading something.
        >>Rember, this isnt a purposeful program, its intended to look computery,
        >>and thats about all
        >>>
        >>thanks for any help,,, ~3than
        >>
        >#include <ios>
        >#include <iostream>
        >#include <ctime>
        >#include <string>
        >>
        >void status (const std::string text,
        > unsigned int duration,
        > unsigned int interval)
        >{
        > std::cout << text;
        > std::time_t last;
        > std::time_t begin(std::time (0));
        >>
        > while(std::diff time(last = std::time(0), begin) < duration)
        > {
        > while(std::diff time(std::time( 0), last) < interval)
        > ; /* empty statement */
        >>
        > std::cout << '.' << std::flush;
        > }
        >}
        >>
        >int main()
        >{
        > status("connect ing", 10, 2);
        > std::cout << " Done.\n";
        > return 0;
        >}
        >>
        >>
        >-Mike
        >
        >
        Thank you very much, but is this the simpilist way to do this, because
        i'd like to be able to use this feature elsewhere, and im not sure
        exactly what you did there. Thanks ALOT thou, very helpfull.
        >
        There are other options depending on your platform. POSIX systems have a
        "sleep" function, for example. The advantage of Mike Wahler's approach
        is that it is all standard C++, so it should work anywhere that has a
        C++ compiler.

        --
        Alan Johnson

        Comment

        • 3than7

          #5
          Re: Wait, pause, sleep, w/e


          yes, i played around with it and figured out how to make it work for my
          purposes
          thanks a bunch mike!

          Comment

          Working...