<div>hello</div><div>I have made kind of calculator</div><div>as like following code</div><div>#lang scheme</div><div>(define ns (make-base-namespace))</div><div>(define (calc)</div><div> (let ((expression (read)))</div><div>
(if (eq? expression 'exit)</div><div> (exit)</div><div> (printf "~A ~n" (eval expression ns))))</div><div> (calc))</div><div>(calc)</div><div><br></div><div>since I learned big-bang function,</div>
<div>I am intending to making more graphical program</div><div>which read from user and display texts and when user hit the enter button,</div><div>the written string evaluated and pop out to the window </div><div>(without command line prompt)</div>
<div>but I still stuck at convert string to evaluatable data </div><div><br></div><div>my source code(still underconstruction) is looks like this</div><div>#lang scheme</div><div>(require 2htdp/image)</div><div>(require 2htdp/universe)</div>
<div>(define ns (make-base-namespace))</div><div>(define result "")</div><div>(define command "")</div><div>(define input (open-input-string command))</div><div>(define output (open-output-string))</div>
<div>(define (draw n)</div><div> (overlay (text (string-append command "=" result)15 "blue") (square 400 "outline" "black")))</div><div>(define (keyboard n key)</div><div> (cond </div>
<div> [(not (equal? key "\r")) (set! command (string-append command key))]</div><div> [(equal? key "\r") (begin </div><div> (write command output)</div><div> (set! result (eval (read input) ns)))])n)</div>
<div>(big-bang 0</div><div> (on-tick add1)</div><div> (on-draw draw)</div><div> (on-key keyboard))</div><div><br></div><div>I dare not ask for correcting my whole source code</div><div>I need an little advice from you</div>
<div>what I have to do for change string to evaluatable code?</div><div><br></div><div>thanks in advanced</div><div><br></div><div>sorry for messy code</div>