Here is an example program that enters a factorial procedure and computes (fact 4). To run this program, start DrScheme, click on the ``Console'' button, load this program and run (go). Then bring the DrScheme window to the front and click the mouse in the DrScheme window.
(define go
(lambda ()
(sleep 3)
(mred:test:new-window (get-panel '(0 0 0 1))) ; definitions canvas
(mred:test:menu-select "Edit" "Select All")
(mred:test:menu-select "Edit" "Delete")
(type-line "(define fact")
(type-line "(lambda (n)")
(type-line "(if (zero? n)")
(type-line "1")
(type-line "(* n (fact (sub1 n))))))")
(mred:test:button-push (get-panel '(0 0 0 0 5 0))) ; check-syntax button
(mred:test:button-push (get-panel '(0 0 0 0 5 3))) ; execute button
(sleep 3)
(type-line "(fact 4)")
(sleep 1)
(printf "Test complete. Pending actions: ~s~n"
(mred:test:number-pending-actions))))
(define type-line
(lambda (str)
(for-each mred:test:keystroke (string->list str))
(mred:test:keystroke #\return)))
(define get-panel
(lambda (path)
(let loop ([path path]
[panel (send (mred:test:get-active-frame) get-top-panel)])
(if (null? path)
panel
(loop (cdr path)
(list-ref (ivar panel children) (car path)))))))