[plt-scheme] HTDP Exercise 22.3.3. - Hint needed

From: Guenther Schmidt (gue.schmidt at web.de)
Date: Sat Nov 29 10:30:20 EST 2003

Hi,

I've developed the code following code but I have one problem: How do I 
identify the button that was pressed?

When I specify the callback function to a button do I need to pass 
specific arguments, in short: I don't know how it's done.

;; model

(define pad
   '((1 2 3)
     (4 5 6)
     (7 8 9)
     (\# 0 *)))

(define pad2
   '((1 2 3  +)
     (4 5 6  -)
     (7 8 9  *)
     (0 = \. /)))


;; view

(define md (make-message "n"))

(define (pad->gui title a-list)
   (cons
    (list (make-message title))
    (cons (list md)
          (traverse a-list))))

(define (traverse a-list)
   (cond
     ((empty? a-list) empty)
     ((list? a-list)
      (cons (traverse (first a-list))
            (traverse (rest a-list))))
     (else
      (make-button
       (cond
         ((symbol? a-list) (symbol->string a-list))
         (else (number->string a-list)))
       test))))

;; controller

(define (test e)
   (draw-message md "2"))

(create-window (pad->gui "PHONE" pad))



Cheers

Guenther




Posted on the users mailing list.