Mercurial > urweb
changeset 1630:4798ad652c94
Stop [read] from raising an exception for invalid [int] strings
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sun, 04 Dec 2011 15:13:53 -0500 (2011-12-04) |
parents | 438561303d02 |
children | 747f94ac5fc2 |
files | lib/js/urweb.js tests/parseInt.ur |
diffstat | 2 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/js/urweb.js Sun Dec 04 14:40:12 2011 -0500 +++ b/lib/js/urweb.js Sun Dec 04 15:13:53 2011 -0500 @@ -972,7 +972,7 @@ if (s == "0") return s; else - er("Can't parse int: " + s); + return {}; } function pi(s) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/parseInt.ur Sun Dec 04 15:13:53 2011 -0500 @@ -0,0 +1,9 @@ +fun main () : transaction page = + s <- source ""; + return <xml><body> + <ctextbox source={s}/> + <button onclick={n <- get s; + case read n of + None => alert "Invalid" + | Some n => alert (show (n + 1))}/> + </body></xml>