sunet/web-server/root/surflets/add-surflet.scm

55 lines
1.5 KiB
Scheme
Raw Permalink Normal View History

2003-01-19 11:57:27 -05:00
(define-structure surflet surflet-interface
(open surflets
scheme-with-scsh)
(begin
(define number-input (make-number-field))
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)
(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)))
(bindings (get-bindings result))
2003-06-21 11:27:20 -04:00
(number (input-field-value number-input bindings)))
(if number
number
(get-number title "Please enter a valid number."))))
2003-03-09 14:57:09 -05:00
(define (get-number-1)
(get-number "Addition - Step one" "First number:"))
2003-03-09 14:57:09 -05:00
(define (get-number-2)
(get-number "Addition - Step two" "Second number:"))
(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)
(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.")
))