aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/fromString.ur
blob: 673503aea300bbf99fb7ca19ed9f27c427aa1c34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
fun s2i s =
        case stringToInt s of
          None => 0
        | Some n => n

fun s2f s =
        case stringToFloat s of
          None => 0.0
        | Some n => n

fun s2b s =
        case stringToBool s of
          None => False
        | Some b => b

fun main () : transaction page = return <html><body>
        Error = {cdata (show _ (s2i "Error"))}<br/>
        3 = {cdata (show _ (s2i "+3"))}<br/>
        <br/>
        Error = {cdata (show _ (s2f "Error"))}<br/>
        98.76 = {cdata (show _ (s2f "98.76"))}<br/>
        <br/>
        Error = {cdata (show _ (s2b "Error"))}<br/>
        False = {cdata (show _ (s2b "false"))}<br/>
        True = {cdata (show _ (s2b "trUE"))}<br/>
</body></html>