Page 1 of 1

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

Posted: Wed Jun 21, 2017 8:42 pm
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