(*
fun returnPage title pic body = Web.return
`
^title
^title
^(Quot.toString body)
Served by SMLserver
`
*)
fun returnPage title pic body =
Page.return title `
^(Quot.toString body)
`
fun mk_form (n:int) =
``
val _ =
case FormVar.wrapOpt FormVar.getNatErr "n"
of NONE =>
returnPage "Guess a number between 0 and 100"
"bill_guess.jpg"
(mk_form (Random.range(0,100) (Random.newgen())))
| SOME n =>
case FormVar.wrapOpt FormVar.getNatErr "guess"
of NONE =>
returnPage "You must type a number - try again"
"bill_guess.jpg" (mk_form n)
| SOME g =>
if g > n then
returnPage "Your guess is too big - try again"
"bill_large.jpg" (mk_form n)
else if g < n then
returnPage "Your guess is too small - try again"
"bill_small.jpg" (mk_form n)
else
returnPage "Congratulations!" "bill_yes.jpg"
`You guessed the number ^(Int.toString n)
Play again?`