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

    Join Date
    Sep 2008
    Posts
    2
    Rep Power
    0

    Missing prompt for user input


    I am a very beginner on Ruby. My first program seems to cause me a problem already and I really need some help!. I am using SciTE text editor to write a simple codes as follow:

    puts "Enter your name: "
    name=gets.chomp
    puts " Your name is: " + name

    The problem: the prompt: "enter your name" does not appear on the tex editor screen to allow the user to respond. However, it would appear afterward instead (after user enter something).
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2004
    Location
    Constant Limbo
    Posts
    989
    Rep Power
    363
    Try to flush the output buffer after printing:
    Code:
    puts "Enter your name: "
    $stdout.flush
    name = gets.chomp
    Should do what you are asking for.
    True happiness is not getting what you want, it's wanting what you've already got.

    My Blog
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2008
    Posts
    2
    Rep Power
    0

    Missing prompt for user input


    Originally Posted by L7Sqr
    Try to flush the output buffer after printing:
    Code:
    puts "Enter your name: "
    $stdout.flush
    name = gets.chomp
    Should do what you are asking for.
    It works very well! Thank you very much to L7Sqr for helping out. I know others peers have same problem and I will let them know.

IMN logo majestic logo threadwatch logo seochat tools logo