On 3/8/06, Francesco Montorsi <[EMAIL PROTECTED]> wrote:
> 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

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

It's only a single function call right?  setlocale(LC_NUMERIC, "C")

I think that it's probably best to just call it in the program code as
you did. I can't think of anything else right now that we would want
to initialize for wxLua (since all my attempts to autoinitialize the
bindings have failed for various different platforms) so it's probably
more clear to have it like you do. Please commit it.

Thanks,
    John Labenski


-------------------------------------------------------
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&kid0944&bid$1720&dat1642
_______________________________________________
Wxlua-users mailing list
Wxlua-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wxlua-users

Reply via email to