home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / OS2XLSP1.ZIP / TOPLEVEL.LSP < prev    next >
Text File  |  1988-07-19  |  2KB  |  52 lines

  1. ; toplevel.lsp -- OS2XLISP
  2. ; Andrew Schulman 27-April-1988
  3. ; uses KBDSTRINGIN and Estes's ALIAS program
  4.  
  5. ; make sure they have ALIAS replacement for KBDSTRINGIN
  6. (if (not (define tmp (loadmodule "alias")))
  7.     (error "TOPLEVEL is not really useable without ALIAS.DLL")
  8.     (freemodule tmp))
  9.  
  10. ; set up for KbdStringIn call       
  11. (define KBDSTRINGIN (getprocaddr kbdcalls "KBDSTRINGIN"))
  12. (define length (makelong 255 0))        ; 2-word structure
  13. (define buf (make-string (int-char 32) 255))
  14.  
  15. ; could hold off all ^C and ^break with DOSHOLDSIGNAL
  16.  
  17. (define (my-read-line)
  18.     (call KBDSTRINGIN buf (addr length) (word 0) (word 0))
  19.     (terpri)
  20.     (subseq buf 0 (shr length 16)))     ; trim string
  21.  
  22. (define (get-expr)
  23.     (do
  24.         ((s "") (op 1) (cl 0))              ; init
  25.         ((>= cl op) s)                      ; test, retval
  26.         (setf s (strcat s " " (my-read-line)))
  27.         (setf op (char-count s #\())
  28.         (setf cl (char-count s #\)))))
  29.             
  30. (define (read-eval-print)
  31.     (print (eval (read (make-string-input-stream (get-expr))))))
  32.         
  33. (define (do-prompt)
  34.     (if (eq 'STRING (type-of *prompt*))
  35.         (princ *prompt*)
  36.     ; else
  37.         (eval *prompt*)))
  38.             
  39. ; catch any errors
  40. (define *breakenable* nil)
  41.  
  42. ; THE LOOP          
  43. (while t
  44.     (do-prompt)
  45.     (read-eval-print))
  46.         
  47. ; lines are now editable with cursor keys
  48. ; backward-scrollable semi-history
  49.  
  50. ; problem! tabs not expanded! (modify source?)
  51.  
  52.