A bug in NewLISP-tk ?

For the Compleat Fan
Locked
newBert
Posts: 156
Joined: Fri Oct 28, 2005 5:33 pm
Location: France

A bug in NewLISP-tk ?

Post by newBert »

When I launch this code :

Code: Select all

(print "Please, enter a number : ")
(set 'nn (eval-string (read-line)))
In the NewLISP console, I get :
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 :
newLISP v.8.8.8 on Win32 MinGW.

> Please, enter a number : 2
2
> nn
nil

>

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

Not sure how you launch it, when I load it from a file i get:
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!
Hans-Peter

newBert
Posts: 156
Joined: Fri Oct 28, 2005 5:33 pm
Location: France

Post by newBert »

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 ?

HPW
Posts: 1390
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany
Contact:

Post by HPW »

Strange ? :)
Maybe Lutz can explain better, but newLISP-Tk is sometime a bit more tricky than the plain console.
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. ;-)
Hans-Peter

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

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:

Code: Select all

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

Code: Select all

newLISP v.8.8.9 on Win32 MinGW.

> enter a number:1234

> 
> nn
1234
> 
Lutz

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by 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

newBert
Posts: 156
Joined: Fri Oct 28, 2005 5:33 pm
Location: France

Post by newBert »

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 :
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 :
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 :
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 :
55
newLISP v.8.8.9 on Win32 MinGW, execute 'newlisp -h' for more info.

> n
55
>

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

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'

Code: Select all

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

Code: Select all

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
Posts: 156
Joined: Fri Oct 28, 2005 5:33 pm
Location: France

Post by newBert »

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 :
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

Locked