2003-01-19 11:57:27 -05:00
|
|
|
(define-structure surflet surflet-interface
|
|
|
|
(open surflets
|
2002-12-08 10:49:27 -05:00
|
|
|
scheme-with-scsh)
|
2002-09-24 05:12:58 -04:00
|
|
|
(begin
|
|
|
|
|
2003-07-08 17:22:06 -04:00
|
|
|
(define number-input (make-number-field))
|
2002-09-24 05:12:58 -04:00
|
|
|
|
2003-06-21 11:27:20 -04:00
|
|
|
(define (create-input-page title input-text number-input)
|
2003-03-09 14:57:09 -05:00
|
|
|
(lambda (new-url)
|
|
|
|
`(html (title ,title)
|
|
|
|
(body
|
|
|
|
(h2 ,title)
|
|
|
|
(p
|
|
|
|
(surflet-form ,new-url
|
|
|
|
,input-text " "
|
2003-06-21 11:27:20 -04:00
|
|
|
,number-input
|
2003-03-09 14:57:09 -05:00
|
|
|
,(make-submit-button)))
|
|
|
|
(hr)
|
2003-03-09 15:15:08 -05:00
|
|
|
(p (url "/" "Return to main menu.") (br)
|
|
|
|
(url "add-surflet.scm" "Start new calculation."))))))
|
2003-03-09 14:57:09 -05:00
|
|
|
|
2003-01-16 07:09:49 -05:00
|
|
|
(define (get-number title input-text)
|
2003-03-09 14:57:09 -05:00
|
|
|
(let* ((result (send-html/suspend
|
2003-06-21 11:27:20 -04:00
|
|
|
(create-input-page title input-text number-input)))
|
2003-02-21 04:50:49 -05:00
|
|
|
(bindings (get-bindings result))
|
2003-06-21 11:27:20 -04:00
|
|
|
(number (input-field-value number-input bindings)))
|
2003-02-21 04:50:49 -05:00
|
|
|
(if number
|
|
|
|
number
|
|
|
|
(get-number title "Please enter a valid number."))))
|
2002-09-24 05:12:58 -04:00
|
|
|
|
2003-03-09 14:57:09 -05:00
|
|
|
(define (get-number-1)
|
|
|
|
(get-number "Addition - Step one" "First number:"))
|
2002-09-24 05:12:58 -04:00
|
|
|
|
2003-03-09 14:57:09 -05:00
|
|
|
(define (get-number-2)
|
|
|
|
(get-number "Addition - Step two" "Second number:"))
|
2002-09-24 05:12:58 -04:00
|
|
|
|
|
|
|
(define (main req)
|
2003-06-22 12:23:16 -04:00
|
|
|
(let ((number-1 (get-number-1))
|
|
|
|
(number-2 (get-number-2)))
|
|
|
|
(show-result (+ number-1 number-2))))
|
|
|
|
|
|
|
|
(define (show-result result)
|
2003-02-21 04:50:49 -05:00
|
|
|
(send-html
|
|
|
|
`(html (title "Result")
|
2003-06-22 12:23:16 -04:00
|
|
|
(body (h2 "Result")
|
|
|
|
(p ,result
|
|
|
|
(hr)
|
|
|
|
(p (a (@ (href "add-surflet.scm"))
|
|
|
|
"Make new calculation.") (br)
|
|
|
|
(a (@ (href "/"))
|
|
|
|
"Return to main menu."))))))
|
|
|
|
"This string will never be evaluated.")
|
|
|
|
|
2002-09-24 05:12:58 -04:00
|
|
|
))
|
|
|
|
|