Francesco Montorsi ha scritto:
John Labenski ha scritto:
On 3/7/06, Francesco Montorsi
<[EMAIL PROTECTED]> wrote:
Hi John,
I see you added that very nice example and also a screenshot for
it... unfortunately it doesn't run on my linux with latest wxLua
compiled & installed:
[EMAIL PROTECTED]:~/work/wxLua/samples$ wxlua wxluasudoku.wx.lua
wxLua: Syntax error during pre-compilation
wxluasudoku.wx.lua:193: malformed number near `9.1'
wxLua: Syntax error during pre-compilation
Maybe the dot must be replaced with a comma ?
Doing the replace in line 193 makes wxLua complain for next occurrences
.... probably if I'd solve them all, it would just run.
What I do not understand is why it works with you ?
It works fine here, I want to divide by the number 9.1 = 91E-1.
Could it be a locale problem ?
It seems like it is, I don't know how to solve it for you. Change you
system locale to "C" maybe? I think that's what I use.
Changing locale it works.
there is something at bottom of
http://www.lua.org/pil/22.2.html
but I've tried to run just 'lua' and not 'wxlua' and it accepts also
dots as decimals... so the problem seems to be in wxLua or wxWidgets.
Searching for locale in wxLua gives few results and it looks like a
wxLocale is never created in wxLua. Maybe it's some initialization stuff
done by wx...
I'll try to dig in this problem..
I've found a fix for this:
Index: apps/wxlua/src/wxlua.cpp
===================================================================
RCS file: /cvsroot/wxlua/wxLua/apps/wxlua/src/wxlua.cpp,v
retrieving revision 1.27
diff -b -u -2 -r1.27 wxlua.cpp
--- apps/wxlua/src/wxlua.cpp 8 Mar 2006 02:46:37 -0000 1.27
+++ apps/wxlua/src/wxlua.cpp 8 Mar 2006 22:26:29 -0000
@@ -219,4 +219,15 @@
wxInitAllImageHandlers();
+#ifdef __WXGTK__
+ // this call is very important since otherwise scripts using the
decimal
+ // point '.' could not work with those locales which use a
different symbol
+ // (e.g. the comma) for the decimal point...
+ // It doesn't work to put os.setlocale('c', 'numeric') in the Lua
file that
+ // you want to use decimal points in. That's because the file has
been lexed
+ // and compiler before the locale has changed, so the lexer - the
part that
+ // recognises numbers - will use the old locale.
+ setlocale(LC_NUMERIC, "C");
+#endif
+
// Initialize wxLua by first attaching the bindings we want to use
// note: make sure you link to the binding libraries
Index: apps/wxluaedit/src/wxluaedit.cpp
===================================================================
RCS file: /cvsroot/wxlua/wxLua/apps/wxluaedit/src/wxluaedit.cpp,v
retrieving revision 1.12
diff -b -u -2 -r1.12 wxluaedit.cpp
--- apps/wxluaedit/src/wxluaedit.cpp 8 Mar 2006 05:13:46 -0000 1.12
+++ apps/wxluaedit/src/wxluaedit.cpp 8 Mar 2006 22:26:30 -0000
@@ -107,4 +107,15 @@
wxInitAllImageHandlers();
+#ifdef __WXGTK__
+ // this call is very important since otherwise scripts using the
decimal
+ // point '.' could not work with those locales which use a
different symbol
+ // (e.g. the comma) for the decimal point...
+ // It doesn't work to put os.setlocale('c', 'numeric') in the Lua
file that
+ // you want to use decimal points in. That's because the file has
been lexed
+ // and compiler before the locale has changed, so the lexer - the
part that
+ // recognises numbers - will use the old locale.
+ setlocale(LC_NUMERIC, "C");
+#endif
+
// Initialize wxLua by first attaching the bindings we want to use
// note: make sure you link to the binding libraries
since the two diffs are identical and possibly useful to any program
using wxLua bindings and using lua scripts with decimal points, maybe it
should be encapsulated in some global function ?
I've not committed it yet...
Francesco
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Wxlua-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wxlua-users