How do I prompt for user input while a function is running?
My code looks something like this:
fun get infile = ( TextIO.output(TextIO.stdOut, prompt)
; TextIO.flushOut(TextIO.stdOut)
; TextIO.inputLine infile
)
This returns a value of type string option
; normally a line SOME l
, but NONE
on end of file.
To read a line from standard input use TextIO.inputLine from the Standard Basis Library, I think you can just do something like
TextIO.inputLine TextIO.stdIn
Clarification: this returns a string option
type, which is NONE if it is at EOF
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With