#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2006
    Posts
    8
    Rep Power
    0

    Program ends to quickly


    Just for an example:

    #!/usr/bin/ruby
    print "Hello World\n"


    It makes a black window appear, the words "Hello World" Pop up and the screen disappears almost to quickly to see it. How do I make it stay up until I tell it to end (i.e. Hit the enter key to close?)

    I appreciate any help I can get.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 2006
    Posts
    2,270
    Rep Power
    1736
    What you wrote is a console program, so you ideally you should open a command line and run it from there. Get used to doing so, as many of the programs and tools you will use will be command line programs.

    But if you want to create a kludge and keep the window open, ask for user input. Doing something like kludge = gets at the end of the program will do the trick.
    When you ask a question, be prepared to tell us: what have you tried? If you think you don't need to try anything, we will never be interested in helping you. If you agree with the link, and you refuse to answer that question, you are being a hypocrite.

    Need help with broken code? Your question should be like a good bug report: (1) It has the smallest number of steps to reproduce the problem you see (2) It tells us precisely what you expected to see and (3) It tells us what you saw and how it differed from what you expected. We need all three to help you.
    Want better answers? Tell us what you Googled for and what steps you took to answer your own question.

IMN logo majestic logo threadwatch logo seochat tools logo