GizmoWiki:サンドボックス
記事書きのためしページ。
AutoLISP のコード
;;; Debugging functions (defun break (s) (if *BREAK* (progn (princ "BREAK>> (stop with <Enter>)\nBREAK>> ") (princ s) (while (/= (setq s (getstring "\nBREAK>> ")) "") (print (eval (read s))))))) ;bugfix from v1.3! (defun dbg-print (s) ;accepts atoms and lists (if *DEBUG* (if (listp s) (mapcar 'print s) (print s)))) (defun C:DEBUG () (setq *DEBUG* (not *DEBUG*))) ;switch it on and off (defun C:BREAK () (setq *BREAK* (not *BREAK*))) (defun CONT () (setq *BREAK* nil)) ;continue without any interruption ;;;Example (setq *BREAK* T *DEBUG* T) (defun C:TEST () (foreach x '("1" "1.0" "1e-3") (break "in foreach") ; stops evaluation if *BREAK* is on, you can ; enter x and the value of x is printed ; until you enter Enter (setq x (atof x)) ; this is some code which manipulates x (dbg-print x) ; this prints the new value of x ; if *DEBUG* is on ) )
&arguments はおいしいのに...
;;; print a variable number of arguments (of any type) (defun my-princ (x) ;; simple version, for better stuff look at the SDK2: PRINTF.LLB (if (listp x) (mapcar 'princ x) (princ x)))