Tip for Today: extended sysinfo

Started by newdep, April 10, 2008, 04:00:41 PM

Previous topic - Next topic

newdep

Quote;;

;; sysinfo

(define (sysinfo)

 (println (dup "-" 79))

 (println "Current time/date                    : " (date))

 (println "newLisp OS type                      : " ostype)

 (println "init.lsp loaded?                     : "

  (if (or

   (file? (string (env "NEWLISPDIR") "/" "init.lsp"))

   (file? (string (env "HOME") "/" "init.lsp"))

   (file? (string (env "USERPROFILE") "/" "init.lsp"))  

   (file? (string (env "DOCUMENT_ROOT") "/" "init.lsp"))

  ) "yes" "no"))          

 (println (dup "-" 79))  

 (println "Arguments loaded with newLisp        : " (main-args))      

 (println "Current working directory            : " (real-path))      

 (println "newLisp environment                  : " (env "NEWLISPDIR"))

 (println "Current LOCALE                       : " (0 30 (set-locale)) "...")

 (println (dup "-" 79))

 (println "Number of LISP cells                 : " ((sys-info) 0))

 (println "Maximum number of LISP cells constant: " ((sys-info) 1))

 (println "Number of symbols                    : " ((sys-info) 2))

 (println "Evaluation/recursion level           : " ((sys-info) 3))

 (println "Environment stack level              : " ((sys-info) 4))

 (println "Maximum call stack constant          : " ((sys-info) 5))

 (println "Pid of running newLISP process       : " ((sys-info) 6))

 (println "Version number as an integer constant: " ((sys-info) 7))

 (println "Operating system constant            : " ((sys-info) 8))

 (println "Total 'open/opened' net-sessions     : " (length (net-sessions)))

 (println "Total symbols loaded                 : " (length (symbols)))

 (println "Last System Error                    : " (sys-error))

 (println "Last newLisp Error                   : " (error-text (error-number)))

 (println "Last Net Error                       : " (if (net-error) (last (net-error)) 'nil))

 (println (dup "-" 79))

)





Quote
-------------------------------------------------------------------------------

Current time/date                    : Fri Apr 11 00:57:47 2008

newLisp OS type                      : Linux

init.lsp loaded?                     : no

-------------------------------------------------------------------------------

Arguments loaded with newLisp        : ("newlisp" "mods.lsp")

Current working directory            : /home/wizzy/progs

newLisp environment                  : /usr/share/newlisp

Current LOCALE                       : LC_CTYPE=en_US;LC_NUMERIC=C;LC...

-------------------------------------------------------------------------------

Number of LISP cells                 : 835

Maximum number of LISP cells constant: 268435456

Number of symbols                    : 375

Evaluation/recursion level           : 4

Environment stack level              : 2

Maximum call stack constant          : 2048

Pid of running newLISP process       : 5005

Version number as an integer constant: 9307

Operating system constant            : 1

Total 'open/opened' net-sessions     : 0

Total symbols loaded                 : 375

Last System Error                    : 2

Last newLisp Error                   : string expected                  

Last Net Error                       : ERR: Connection failed

-------------------------------------------------------------------------------








Ofcaure you dont need to define all errors...

(error-text) is the way...changed the example above
-- (define? (Cornflakes))