This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
;;;
;;; simplified newlisp ncurses example to get key codes
;;;
;;; import functions from ncurses lib
(set 'ncfuncs '( "initscr" "endwin" "getch" "cbreak" "keypad"))
(define (import-ncurses) (dolist (x ncfuncs ) (import "/usr/lib/libncurses.dylib" x)))
;;; Newlisp-Ncurses
(import-ncurses)
(set 'stdscr (initscr))
(println (format "%ld" stdscr))
(cbreak)
(keypad stdscr 1)
(set 'key (getch))
(endwin)
(println (string "key: " key))
newLISP v.10.6.0 64-bit on OSX IPv4/6 UTF-8 libffi, options: newlisp -h
> (load "udp-client.lsp")
(10 "Cannot bind socket")
nil
Quote
bit 9 will be set for 64-bit (changeable at runtime) versions (add 256)
(http://www.newlisp.org/downloads/newlisp_manual.html#sys-info"> )http://www.newlisp.org/downloads/newlis ... l#sys-info">http://www.newlisp.org/downloads/newlisp_manual.html#sys-info
;; set local to the "C" locale on UTF8
(if utf8
(set-locale "C"))
;; test for 32-bit-ness
(define (bit32?)
(= (& (sys-info -1) (<< 1 9))))
;; define flt32 depending on the bit-ness
(if (bit32?)
(constant 'flt32 flt)
(define (flt32 f)
(first (unpack "ld" (pack "f" f)))))
newLISP v.10.6.0 64-bit on OSX IPv4/6 UTF-8 libffi, options: newlisp -h
> (flt -0.8)
0
newLISP v.10.6.0 32-bit on Win32 IPv4/6 libffi, options: newlisp -h
> (flt -0.8)
-1085485875
Float.floatToIntBits(-0.8f)
newLISP v.10.6.0 32-bit on Win32 IPv4/6 libffi, options: newlisp -h
> (format "%f" -0.8)
"-0.800000"
newLISP v.10.6.0 64-bit on OSX IPv4/6 UTF-8 libffi, options: newlisp -h
> (format "%f" -0.8)
ERR: mismatch in number of arguments in function format : .8
>