When I launch this code :
(print "Please, enter a number : ")
(set 'nn (eval-string (read-line)))
In the NewLISP console, I get :
Quote
Please, 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 :
Quote
newLISP v.8.8.8 on Win32 MinGW.
> Please, enter a number : 2
2
> nn
nil
>
Not sure how you launch it, when I load it from a file i get:
Quote
newLISP 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!
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 ?
Quote
Strange ? :)
Maybe Lutz can explain better, but newLISP-Tk is sometime a bit more tricky than the plain console.
Quote
P.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. ;-)
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
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
in the 3rd and 4th paragraphs
Lutz
Quote
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
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 :
Quote
newLISP 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 :
Quote
newLISP 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 :
Quote
newLISP 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 :
Quote
55
newLISP v.8.8.9 on Win32 MinGW, execute 'newlisp -h' for more info.
> n
55
>
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
Quote
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'
Yes, it works, thanks for the reply.
Your recommendation :
Quote
My 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