Re: Noob question: Function to prompt for input
John Reppy <[email protected]> Sun, 14 Mar 2010 15:19:03 -0500
| Newsgroups | gmane.comp.lang.sml.smlnj |
|---|---|
| Message-ID | <[email protected]> |
The error message is because you have a ";" at the end of the first line followed by a "val". What you want is something like: fun getletter () = let val _ = print "Please enter your guess as a character string: " val SOME ln = TextIO.inputLine TextIO.stdIn in String.substring(ln, 0, 4) end; but note that if the user types in less than four characters, then you are going to get a Subscript exception. - John On Mar 13, 2010, at 10:59 AM, tommy mato wrote: > > I want to do something simple like create a function that prompts for input. > In any other language that would be trivial. I have spent 6 hours at this > today and not getting any closer. I've tried so many combinations. > > Here is my latest version of the function: > > fun getletter _ = (print "Please enter your guess as a character string: "; > val line = valOf (TextIO.inputLine TextIO.stdIn); > String.substring(line, 0, 4)); > > I get back a meaningless error message: > > outer.sml:1.79 Error: syntax error: replacing SEMICOLON with RPAREN > > Any ideas? Thanks in advance. > -- > View this message in context: http://old.nabble.com/Noob-question%3A-Function-to-prompt-for-input-tp27889172p27889172.html > Sent from the SML/NJ mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Smlnj-list mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/smlnj-list > ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev