User input/Text: Difference between revisions

added Fantom example
(added Fantom example)
Line 207:
[0[^'0-$$9>0@>|~][\10*+]#%]d:
w;! d;!.</lang>
 
=={{header|Fantom}}==
 
The 'toInt' method on an input string will throw an exception if the input is not a number.
 
<lang fantom>
class Main
{
public static Void main ()
{
Env.cur.out.print ("Enter a string: ").flush
str := Env.cur.in.readLine
echo ("Entered :$str:")
Env.cur.out.print ("Enter 75000: ").flush
Int n
try n = Env.cur.in.readLine.toInt
catch (Err e)
{
echo ("You had to enter a number")
return
}
echo ("Entered :$n: which is " + ((n == 75000) ? "correct" : "wrong"))
}
}
</lang>
 
=={{header|Forth}}==
342

edits