Skip to content

Commit 4bd76cb

Browse files
committed
按2次等号挂掉问题
1 parent 583f9cf commit 4bd76cb

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

apps/calc.ss

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
(define (app-calc)
21-
(let ((exp "") (exp2 ""))
21+
(let ((exp "") (clear #t))
2222
(glut-init)
2323
(imgui-init)
2424
;(android)
@@ -55,6 +55,7 @@
5555

5656
(if (imgui-button "C" (imgui-make-vec2 88.0 40.0) )
5757
(set! exp "")
58+
(set! clear #t)
5859
)
5960
;;(imgui-same-line)
6061
;;(if (imgui-button "+/-" (imgui-make-vec2 80.0 40.0) )
@@ -125,12 +126,15 @@
125126
)
126127

127128
(imgui-same-line)
128-
(if (imgui-button "=" (imgui-make-vec2 40.0 40.0) )
129+
(if (and (imgui-button "=" (imgui-make-vec2 40.0 40.0) ) clear (> (string-length exp) 0) )
129130
;;(glut-log (infix-prefix (read (open-input-string exp))))
130-
(set! exp (string-append exp (format " = ~a" (eval
131-
(infix-prefix
132-
(read (open-input-string
133-
(string-append (string-append "(" exp) ")"))))))))
131+
(begin
132+
(set! exp (string-append exp (format " = ~a" (eval
133+
(infix-prefix
134+
(read (open-input-string
135+
(string-append (string-append "(" exp) ")"))))))))
136+
(set! clear #f) )
137+
134138
)
135139

136140
(imgui-end)

0 commit comments

Comments
 (0)