(pause msg delay) debug tool - an ubuntu flavor needed

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Locked
CaveGuy
Posts: 112
Joined: Sun Oct 13, 2002 3:00 pm
Location: Columbus Ohio
Contact:

(pause msg delay) debug tool - an ubuntu flavor needed

Post by CaveGuy »

;;
;; (pause msg delay) is a debuging tool that lets me
;; pause in a loop and look at things and in some
;; cases (setq things before continuing.
;;
;; msg is evaled and printed as a string for
;; delay in seconds, if not specified default is 10
;; return key enters and exits eval print loop
;; any other key to bypass delay and continue.
;;
;; this requires windows, I need an ubuntu equivalent
;;
(if (not _kbhit) (import "msvcrt.DLL" "_kbhit" ))
(if (not _getch) (import "msvcrt.DLL" "_getch" ))

(define (key-pressed) ; this is what is needed !
(if (= 0 (_kbhit)) nil
(begin
(setq keyval (_getch))
(if (or (= keyval 0)(= keyval 224)) (_getch))
(setq keypress (char keyval)))))
#
(define (pause msg delay )
(setq delay (if delay delay 10))
(print (string "\n=>: " msg " "))
(if (!= "\r" (dotimes ( x delay (key-pressed)) (sleep 1000))) nil
(while (!= (setq tmp (print "\n=>? ") estring (read-line)) "")
(print (string "=>: " (eval-string estring) ))true)nil))
#
# example
#
(pause "Doing it" 5)
;
;eof
Bob the Caveguy aka Lord High Fixer.

Locked