From 4af92bc3790dfbb38fe08dbaf1c5e0ffc517ac94 Mon Sep 17 00:00:00 2001 From: interp Date: Sun, 9 Mar 2003 19:57:09 +0000 Subject: [PATCH] factor out creating of input page --- .../web-server/root/surflets/add-surflet.scm | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/scheme/httpd/surflets/web-server/root/surflets/add-surflet.scm b/scheme/httpd/surflets/web-server/root/surflets/add-surflet.scm index a3fdefa..e0894e5 100644 --- a/scheme/httpd/surflets/web-server/root/surflets/add-surflet.scm +++ b/scheme/httpd/surflets/web-server/root/surflets/add-surflet.scm @@ -1,43 +1,44 @@ (define-structure surflet surflet-interface (open surflets - url scheme-with-scsh) (begin (define number-input-field (make-number-input-field)) + (define (create-input-page title input-text) + (lambda (new-url) + `(html (title ,title) + (body + (h2 ,title) + (p + (surflet-form ,new-url + ,input-text " " + ,number-input-field + ,(make-submit-button))) + (hr) + (p (URL "/" "Return to main menu.") (br) + (URL "add-surflet.scm" "Start new calculation.")))))) + (define (get-number title input-text) - (let* ((result - (send-html/suspend - (lambda (new-url) - `(html (title ,title) - (body - (h2 ,title) - (p - (surflet-form ,new-url - ,input-text " " - ,number-input-field - ,(make-submit-button))) - (hr) - (p (URL "/" "Return to main menu.") (br) - (URL "add-surflet.scm" "Start new calculation."))))))) + (let* ((result (send-html/suspend + (create-input-page title input-text))) (bindings (get-bindings result)) (number (input-field-value number-input-field bindings))) (if number number (get-number title "Please enter a valid number.")))) - (define (get-number1) - (get-number "Calculation - Step one" "First number:")) + (define (get-number-1) + (get-number "Addition - Step one" "First number:")) - (define (get-number2) - (get-number "Calculation - Step two" "Second number:")) + (define (get-number-2) + (get-number "Addition - Step two" "Second number:")) (define (main req) (send-html `(html (title "Result") (body (h2 "Result") - (p ,(number->string (+ (get-number1) (get-number2))) + (p ,(+ (get-number-1) (get-number-2)) (hr) (p (URL "add-surflet.scm" "Make new calculation.") (br) (URL "javascript:history.go(-2)" "New calculation (same session)")