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

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?

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

Postby CaveGuy » Wed Jun 21, 2017 8:42 pm

;;
;; (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.
CaveGuy
 
Posts: 112
Joined: Sun Oct 13, 2002 3:00 pm
Location: Columbus Ohio

Return to newLISP and the O.S.

Who is online

Users browsing this forum: No registered users and 2 guests