Loading ...
Sorry, an error occurred while loading the content.
 

Re: [PBML] Re: Displaying counter

Expand Messages
  • Sreeram B S
    Hi, Thanks for the reply. I am using the following algorithm to achieve my task: (a) Display the string which prompts for user input. (b) Start the alarm timer
    Message 1 of 4 , Dec 27, 2005
      Hi,
      Thanks for the reply.
      I am using the following algorithm to achieve my task:

      (a) Display the string which prompts for user input.
      (b) Start the alarm timer with the required timeout.
      (c) If the user inputs data, then stop the timer.
      (d) If the user has not input data, upon receiving the SIGALRM (sent on elapse of alarm timer), display appropriate message and quit.

      This works fine. I could arrive at this algorithm from the suggestions you have provided. Thanks once again.

      But, another thing is the display. I am using Linux machine. I want to display the counter ie if the timeout is 10 seconds, then I want to display the seconds remaining for the user to input data. This display must be at the same location on the screen.
      For eg, if 10 is displayed (assuming 10 seconds left), then after 1 second,10 must be erased and 9 must be displayed at the same location on the screen. After 1 second, 9 must be erased and 8 must be displayed at the same location on the screen and so forth. How do I achieve this? In other words, how can I erase (or delete) the contents at a particular location on the screen and write new content to the same location of the screen?

      Kindly suggest.

      Regards,
      Sreeram



      Damien Carbery <daymobrew@...> wrote:
      --- In perl-beginner@yahoogroups.com, Sreeram B S <sreeramabsc@y...>
      wrote:
      >
      > Hello friends,
      > I am into writing of a program which waits for few seconds for
      the user to provide data. If the user does not provide data within
      that period, then the program quits.
      > Now, I would like to display the time remaining for the user to
      input data. This display must be at the same location but the value
      must be decrementing each second and the updated value must be displayed.
      >
      > For eg, if the timer value is 5 seconds, then I would like to
      display 5,4,3,2,1 but at the same location. ( a kind of count-down ).
      > Could anyone kindly guide me through this?
      >
      > I am unaware as to where to make the beginning of this and so, I
      dont have the code to post here. Kindly excuse me for this.
      >
      > Please suggest / guide.
      >
      > Regards,
      > Sreeram
      Look at perlfaq8 "How do I timeout a slow event?"
      http://aspn.activestate.com/ASPN/docs/ActivePerl/5.8/lib/Pod/perlfaq8.html#how_do_i_timeout_a_slow_event
      "How do I timeout a slow event?

      Use the alarm() function, probably in conjunction with a signal
      handler, as documented in Signals in the perlipc manpage and the
      section on ``Signals'' in the Camel. You may instead use the more
      flexible Sys::AlarmCall module available from CPAN.

      The alarm() function is not implemented on all versions of Windows.
      Check the documentation for your specific version of Perl."

      If you are on Windows you might be able to use signals
      http://aspn.activestate.com/ASPN/docs/ActivePerl/5.8/lib/Pod/perlipc.html#signals

      You could have a timeout each second to display the new number. If you
      get to zero you would continue on with the program.






      Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html



      SPONSORED LINKS
      Basic programming language C programming language Computer programming languages The c programming language C programming language List of programming languages

      ---------------------------------
      YAHOO! GROUPS LINKS


      Visit your group "perl-beginner" on the web.

      To unsubscribe from this group, send an email to:
      perl-beginner-unsubscribe@yahoogroups.com

      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


      ---------------------------------






      ---------------------------------
      Yahoo! Shopping
      Find Great Deals on Holiday Gifts at Yahoo! Shopping

      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.