new TRY-INPUT-FIELD-VALUE returns #f, if INPUT-FIELD-VALUE fails

This commit is contained in:
interp 2002-11-07 14:11:05 +00:00
parent 555af5225d
commit a03e5914da
2 changed files with 17 additions and 0 deletions

View File

@ -166,6 +166,7 @@
make-submit-button make-submit-button
make-reset-button make-reset-button
make-image-button make-image-button
try-input-field-value
input-field-value input-field-value
input-field-binding input-field-binding
@ -192,6 +193,8 @@
define-record-types define-record-types
weak ;MAKE-WEAK-POINTER weak ;MAKE-WEAK-POINTER
locks locks
let-opt ;:OPTIONAL
handle-fatal-error
scsh scsh
scheme) scheme)
(files servlets)) (files servlets))

View File

@ -586,6 +586,20 @@
(else (else
(error "no such input-field" input-field bindings))))) (error "no such input-field" input-field bindings)))))
;; Trys to get a value for INPUT-FIELD in BINDINGS. If this fails
;; (i.e. INPUT-FIELD-VALUE returns an error), the default-value is
;; returned. The default-value defaults to #f. NOTE: If you do this
;; with input-fields whose valid values may be the same as the default
;; value, you cannot determine by the result if there was such a value
;; or not. Keep in mind, that INPUT-FIELD-VALUE returns also an error,
;; if there was not such an input field.
(define (try-input-field-value input-field bindings . maybe-default)
(let ((default (:optional maybe-default #f)))
(with-fatal-error-handler
(lambda (condition more)
default)
(input-field-value input-field bindings))))
(define (real-input-field-binding input-field bindings) (define (real-input-field-binding input-field bindings)
(assoc (input-field-name input-field) bindings)) (assoc (input-field-name input-field) bindings))