Turtle.lsp bug in 7.3.7

Started by HPW, November 19, 2003, 09:54:28 AM

Previous topic - Next topic

HPW

Turtle in the new 7.3.7 brings up an error:



bad screen distance "302,1612092"
Hans-Peter

Lutz

#1
>>>

Turtle in the new 7.3.7 brings up an error:



bad screen distance "302,1612092"

>>>



works well over here on Windows XP and Linux in US.



Could it be the comma, which comes from the localized version? In Germany they use decimal comma instead of decimal point! Could it be, that Tcl/Tl works US but newLISP now in German locale?



You could suppress that using the undocumented 'set-locale' function in newLISP. At first do a:



(set-locale 0)



To find out what locales you have, probably it comes back with "de_DE" for Deutschland. The first parameter in 'set-locale' is a config option the second optional parameter would be "de_DE".



These are the options instead of 0:



LC_ALL   Affects all the following categories

LC_COLLATE   Affects strcoll and strxfrm

LC_CTYPE   Affects single-byte character handling functions. The mbstowcs and mbtowc functions are not affected.

LC_MONETARY   Affects monetary formatting by the localeconv function

LC_NUMERIC   Affects the decimal point of non-monetary data formatting. This includes the printf family of functions, and the information returned by localeconv.



LC_TIME   Affects strftime



curently no option is set (0 ) perhaps you should use LC_NUMERIC



(set-locale 0x10 "de_DE")



to mask the decimal comma change?



LC_COLLATE  0x01

LC_CTYPE    0x02

LC_MONETARY 0x04

LC_NUMERIC  0x10

LC_TIME     0x20

LC_ALL      0xFF



I did not document 'set-locale'  yet, because I'm not sure how all these options work, perhaps you can help finding out?



Anyway I will change 'Turtle.lsp' to make it independent of it.



Lutz

HPW

#2
I tried both:



(set-locale 0)
nil

(set-locale 0x10 "de_DE")
"LC_NUMERIC=German_Germany.850n"


But when I then try turtle.lsp it stays the same error.
Hans-Peter

Lutz

#3
I think I explained it the wrong way, its all the opposite:



What newlisp does on startup is:



(set-locale 0xFF "")



which means: Enable all options (0xff, all bits high) and choose the default locale of your local system ("")



do the following to disable LC_NUMERIC:



 (set-locale (& 0xFF (~ 0x10)) "")



This is setting all bits except the LC_NUMERIC bit, you also could do simller and the same:



(set-locale 0xef "")



and you will see the numeric bit turned off.



If it returns 'nil' that means that it couldn't set what you wanted.



Lutz

Lutz

#4
Please try also the following replacement in Turtle.lsp for the function 'draw':

(define (draw )
  (tk ".tw.can create line " (join (map string (map integer points)) " ") " -fill "
   color)
  (tk "update idletasks")
  (set 'points (list newX newY)))


this changes the float coordinnates to integers before sending them over to Tcl/Tk, eliminating the decimal comma.



Lutz

HPW

#5
No it does not work.



No fractal appears, only a red and a blue straight line from top-left to bottom-right (at different screen-position) appears.





So switching the locale is the way to go for now.
Hans-Peter