Anyone have experience with programming tcl and running on Wish85?

Discussion in 'Programmer's Corner' started by hunterage2000, Mar 8, 2017.

  1. hunterage2000

    Thread Starter Senior Member

    May 2, 2010
    I am new to tcl and I'm trying to prompt a users input. I've looked at loads of examples on the web but nothing seems to work.

    I've tried the following code:

    Code (Text):
    1. puts "Enter your name: "
    2. flush stdout
    3. set name [gets stdin]
    4. puts "Hello $name"
    The output on Wish85 is giving:

    Enter your name:

    So for what ever reason the script is not asking for a user input.

    Does anyone know why? I assume the code is wrong.
  2. MrSoftware

    Senior Member

    Oct 29, 2013
    I'm not familiar with TCL or Wish85, so taking a guess; it's possible your stdin buffer has something in it so your call to get from stdin is grabbing the data that's already in the stdin buffer. Try flushing stdin before you ask the user for input.

    Also check your call to get the data from stdin to see if it's blocking (will it wait for input), or does it just check for data on stdin and then return whether there's data or not. If it's choice B, then either look for a different call that will block until data is present on stdin, or call your function over and over in a loop so it reads from stdin until there is data present (read until you receive a carriage return). You might want to put a sleep in the loop so your CPU isn't pegged.
  3. dl324

    AAC Fanatic!

    Mar 30, 2015
    Works for me. What OS are you running on? Are you using wish or are you writing a script?