A bug in NewLISP-tk ?

Started by newBert, June 02, 2006, 08:07:22 AM

Previous topic - Next topic

newBert

When I launch this code :


(print "Please, enter a number : ")
(set 'nn (eval-string (read-line)))


In the NewLISP console, I get :
QuotePlease, enter a number : 2

newLISP v.8.8.8 on Win32 MinGW, execute 'newlisp -h' for more info.



> nn

2


>


but in the NewLISP-tk console :
QuotenewLISP v.8.8.8 on Win32 MinGW.



> Please, enter a number : 2

2

> nn

nil


>
<r><I>>Bertrand<e></e></I> − <COLOR color=\"#808080\">><B>newLISP<e></e></B> v.10.7.6 64-bit <B>>on Linux<e></e></B> (<I>>Linux Mint 20.1<e></e></I>)<e></e></COLOR></r>

HPW

#1
Not sure how you launch it, when I load it from a file i get:


QuotenewLISP v.8.8.8 on Win32 MinGW.



> Please, enter a number : 10



> nn

10

> Please, enter a number : 48



> nn

48

>


After the input of the number I had to press enter twice!
Hans-Peter

newBert

#2
Ok, I launched the code from a text/script editor (in this case : ConTEXT).

If I load the script with NewLISP-tk (File/Load..) it works as you said and nn get the right value.

Strange ? :)



P.S.: Is there a good, light and easy-to-use script-editor for NewLISP (or other), aside ConTEXT or Crimson's Editor ?
<r><I>>Bertrand<e></e></I> − <COLOR color=\"#808080\">><B>newLISP<e></e></B> v.10.7.6 64-bit <B>>on Linux<e></e></B> (<I>>Linux Mint 20.1<e></e></I>)<e></e></COLOR></r>

HPW

#3
QuoteStrange ? :)


Maybe Lutz can explain better, but newLISP-Tk is sometime a bit more tricky than the plain console.


QuoteP.S.: Is there a good, light and easy-to-use script-editor for NewLISP (or other), aside ConTEXT or Crimson's Editor ?


I use Ultraedit for all my Programming-Languages. Not light and not free but powerfull. I can configure highlighting/autocomplete etc. for 20 different languages at once.



But editors are a matter of taste. ;-)
Hans-Peter

Lutz

#4
Quote
Strange ? :)


I have tried this on both, Win32 and Mac OS X newLISP-tk and cannot see the problem newbert is seeing loading this code from the newLISP-tk frontend or executing the second statement interactively:

(print "enter a number:")
(set 'nn (eval-string (read-line)))



newLISP v.8.8.9 on Win32 MinGW.

> enter a number:1234

>
> nn
1234
>


Lutz

Lutz

#5
may be newbert's Windows installation does something special with Std I/O, read this in the newlisp-tk manual: http://newlisp.org/downloads/newlisp-tk.html#special">http://newlisp.org/downloads/newlisp-tk.html#special



in the 3rd and 4th paragraphs



Lutz

newBert

#6
QuoteI have tried this on both, Win32 and Mac OS X newLISP-tk and cannot see the problem newbert is seeing loading this code from the newLISP-tk frontend or executing the second statement interactively


Sorry, for my (poor) english. I'll try to sum up more clearly ;)



Here is the code : (set 'n (eval-string (read-line)))



- Interactively, it works right on both console newlisp and newlisp-tk :
QuotenewLISP v.8.8.9 on Win32 MinGW.



> (set 'n (eval-string (read-line)))

55

55

> n

55

>


I put the code in a script file named test.lsp, for instance. I launch the newlisp-tk console and I load the script into it (Menu File/Load ...) :



- In this way, it still works right but I must type <Enter> twice :
QuotenewLISP v.8.8.9 on Win32 MinGW.



> 55



> n

55

>


- Now if I launch the script file (test.lsp) in newlisp-tk with the help of a batch file or with the very usefull run.exe or from a text editor :
QuotenewLISP v.8.8.9 on Win32 MinGW.



> 55

55

> n

nil

>


- If I launch the script in newlisp by double-clicking on the file, there is no problem :
Quote55

newLISP v.8.8.9 on Win32 MinGW, execute 'newlisp -h' for more info.



> n

55

>
<r><I>>Bertrand<e></e></I> − <COLOR color=\"#808080\">><B>newLISP<e></e></B> v.10.7.6 64-bit <B>>on Linux<e></e></B> (<I>>Linux Mint 20.1<e></e></I>)<e></e></COLOR></r>

Lutz

#7
The read-line is interfering with 'silent' used when loading programs when using newlisp-tk and is also interfering with std I/O when newLISP-tk starts up and established connection with newlisp in the backend.



The first enter you have to do when loading your program after newlisp-tk is up, is necessary to come out of the 'silent'.



You can simulate this by adding an additional 'read-line'



; porgram newbert
(print "enter a number:")
(read-line)
(set 'nn  (eval-string (read-line)))


Now doing:



c:> newlisp-tk newbert


on the command line or from a batch file will work but you have to hit enter twice, because the first 'read-line' is used up by the load/setup process.



My suggesrtions is not to mix  standard I/O method of input/output with a newLISP-tk GUI program. Either use 'print' and 'read-line' and use the standalone newlisp.exe executable or use the newLISP-tk GUI frontend, but then use the Tcl/Tk GUI facilities to do input/output dialogs with your program.



Lutz

newBert

#8
QuoteThe first enter you have to do when loading your program after newlisp-tk is up, is necessary to come out of the 'silent'.



You can simulate this by adding an additional 'read-line'


Yes, it works, thanks for the reply.



Your recommendation :
QuoteMy suggesrtions is not to mix standard I/O method of input/output with a newLISP-tk GUI program.

seems to me absolutely obvious now !



Bertrand
<r><I>>Bertrand<e></e></I> − <COLOR color=\"#808080\">><B>newLISP<e></e></B> v.10.7.6 64-bit <B>>on Linux<e></e></B> (<I>>Linux Mint 20.1<e></e></I>)<e></e></COLOR></r>