;(Note: This entire code section can be copied to a file for testing.)
;
; Hi Lutz!
;
; I'm having a problem with the following console code
; using newLISP v.9.3.11 on Win32 IPv4
;
(print "Press <Enter> key to input name. ")
(setq key (read-key))
(println "Key pressed: " key)
(if (= key 13)
(begin
(print "Enter name: ")
(setq line (read-line))
(println line)
)
)
;
; Program output:
; ---------------------------------------------------------
; Press <Enter> to input name. Key pressed: 13
; Enter name:
; ---------------------------------------------------------
;
; Program continues without allowing line to be input.
;
; So let's try a different key...
;
(print "Press </> key to input name. ")
(setq key (read-key))
(println "Key pressed: " key)
(if (= key 47)
(begin
(print "Enter name: ")
(setq line (read-line))
(println line)
)
)
;
; Program output:
; ---------------------------------------------------------
; Press </> to input name. Key pressed: 47
; Enter name: /
; ---------------------------------------------------------
;
; This time it allows input, but prepends "/" to the input
; prompt. Typing in the name and pressing <Enter> is now
; allowed.
;
; ---------------------------------------------------------
; Enter name: /xytroxon <Enter>
; /xytroxon
; ---------------------------------------------------------
;
; Pressing <Backspace> will erase the extra "/". So the
; problem is that the (read-key) function is not consuming
; the key press and is carried over into (read-line)...
;
; -- xytroxon
(exit)
I have tried your program on Mac OS X, FreeBSD and Solaris using 10 for the enter key and on Windows XP SP 2 using enter with 13, and they all work correctly, producing the following (on Win32 with 13)
Press <Enter> key to input name. Key pressed: 10
Enter name: hello world
hello world
What OS are you using?
ps: seeing the 13, I guess your are using Windows. Are you using the standard Windows command shell or something special?
This is on a Windows 98 machine from a MSDOS window.
Perhaps you can find older Windows SDK documentation, lookup an appropriate function for character input and make it available to newLISP using 'import'.
Quote from: "Lutz"
Perhaps you can find older Windows SDK documentation, lookup an appropriate function for character input and make it available to newLISP using 'import'.
Yes, I can do that.
It's just strange, as newLISP works so smoothly otherwise!
newLISP breaths newLIFE into "This Old Notebook"! (Isn't that a newPBS show? :;
Using the newLISP wiki as a PIM with the very light weight Abyss web server has been greaat fun!
//http://www.aprelium.com/
-- xytroxon