locale problem in button-demo.lsp (OSX, 10.6.0)

Guiserver, GTK-server, OpenGL, PostScript,

locale problem in button-demo.lsp (OSX, 10.6.0)

Postby t3o » Wed Aug 20, 2014 7:32 pm


I have OSX with newlisp 10.6.0 and newLISP-GS v.1.63 installed with homebrew.

I tried the button-demo.lsp from http://www.newlisp.org/guiserver/guiserver.lsp.html and ran into an error.

The line

Code: Select all
(gs:set-color 'ColorPanel (random) (random) (random))

resulted in a message "Could not invoke method set-color with MAIN:ColorPanel" in a gui dialog.

Code: Select all
(println (random))
to the code printed something like:

I could fix the problem by either setting the locale to "en_US" (from "de_DE.UTF-8") or by converting the random number to a string with "," replaced by ".":

Code: Select all
; use prandom instead of random:
(define (prandom)
   (replace "," (string (random)) ".")

Shouldn't the locale be irrelevant as there's no output in button-demo.lsp?
What I mean is.. shouldn't the random float be just a value -- nothing that has comma or period when interpreting its value?

(Is there an implicit conversion to a string where the locale plays its role? Is that useful?)

Posts: 7
Joined: Tue Dec 11, 2012 9:50 pm

Re: locale problem in button-demo.lsp (OSX, 10.6.0)

Postby Lutz » Thu Aug 21, 2014 2:05 am

The message protocol with guiserver.jar is text-based and relies on the locale set to “C” to guarantee the “.” (dot) as decimal separator. This is why all demo programs start with the statement (set-locale “C”). Unless the homebrew installer has changed this, you should not see this error.

If you are running newLISP on OSX you can use the installer from the newlisp.org website, no homebrew installer is required.
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Return to newLISP Graphics & Sound

Who is online

Users browsing this forum: No registered users and 1 guest