Anyone have experience with programming tcl and running on Wish85?

Thread Starter

hunterage2000

Joined May 2, 2010
487
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:
puts "Enter your name: "
flush stdout
set name [gets stdin]
puts "Hello $name"
The output on Wish85 is giving:

Enter your name:
Hello

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

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

MrSoftware

Joined Oct 29, 2013
1,906
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.
 
Top