Hello all,

I'm trying to make a very simple tutorial stepping through elements of 
PicoLisp.  there's a little guessing game first in the repl, and now i'm trying 
to add the gui.  It works fine, except there is suddenly an extra "+" character 
after clicking a button for the second time.

Any idea what might be going on?

# 2019-08-08
# shoshin

(load "@lib/http.l" "@lib/xhtml.l" "@lib/form.l" "@lib/ps.l")

# Game
##----

(default *Bounds '(1 . 100))

(de small ()
   (car *Bounds) )

(de big ()
   (cdr *Bounds) )

(de guess-my-number ()
   (if (> (small) (big))
      (msg "cheat")
      (/ (+ (small) (big)) 2) ) )

(de smaller ()
   (set '*Bounds (cons (small) (dec (guess-my-number))))
   (guess-my-number) )

(de bigger ()
    (set '*Bounds (cons (inc (guess-my-number)) (big)))
    (guess-my-number) )

# Gui
#-----

(de guess ()
   (app)
   (default *Guess (guess-my-number))
   (action
      (html 0 "Guess My Number" "@lib.css" NIL
         (form NIL
            (<div> 'main
               (gui '(+Style +Var +TextField) "guess" '*Guess)
               (<div> 'buttons
                  (gui '(+JS +Button) "Smaller" '(setq *Guess (smaller)))
                  (gui '(+JS +Button) "Bigger" '(setq *Guess (bigger))) ) ) ) ) 
) )

(de go ()
   (server 8080 "!guess") )

Sent with [ProtonMail](https://protonmail.com) Secure Email.

Reply via email to