home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Developer / macgambit-20-compiler-src-p1 / Examples / text-window-demo.scm < prev    next >
Encoding:
Text File  |  1994-07-26  |  712 b   |  29 lines  |  [TEXT/gamI]

  1. ; Window port demo
  2.  
  3. ; (query prompt) pops up a window, displays the prompt and returns the
  4. ; expression typed in the window.  Note that a window is both an input and
  5. ; output port.
  6.  
  7. (define (query prompt)
  8.   (let ((p (open-text-window "Query")))
  9.     (display prompt p)
  10.     (let ((x (read p)))
  11.       (close-output-port p)
  12.       x)))
  13.  
  14. ; (pretty obj) pops up a window with the pretty printed representation
  15. ; of 'obj'.  Note that the result of 'pretty' is a port.  You should close
  16. ; this port to get rid of the window.
  17.  
  18. (define (pretty obj)
  19.   (let ((p (open-text-window "Pretty")))
  20.     (pp obj p)
  21.     p))
  22.  
  23.  
  24. (define n (query "Enter a number: "))
  25.  
  26. (let ((p (pretty query)))
  27.   (mac#delay 300)
  28.   (close-output-port p))
  29.