On 7/11/07, Leslie Newell <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am a fairly long term user of lua and wxWidgets and I have just
> started using wxLua. I am using a fairly current snapshot.
>
> I am having a couple of issues with wxConfig at the moment. First, why
> is the value pushed on to the return stack first then the read flag?
> Normally if you specify a default value you don't care if a value was
> actually read from the config or not. Currently reading from wxConfig
> can be clumsy. For instance:
>
> dummy,val = cfg:Read("Foo",1) --cfg is a valid wxConfig object
> myRadioBox:SetSelection(val)
>
> If the values are pushed in the opposite order I can do this, which is
> much simpler:
>
> myRadioBox:SetSelection(cfg:Read("Foo",1))
>
> I notice that in earlier versions of wxLua, the order is the other way
> round. Why was it changed?
It was changed because every other function that returns multiple
values all returned the return value of the function as the first
parameter. I have been trying to reduce the number of "gotcha's" in
wxLua to make it less annoying for some, but more annoying for others.
:)
You can use
myRadioBox:SetSelection(select(cfg:Read("Foo",1), 2))
> My next problem is with a wxCheckBox. How do I explicitly convert a
> number to a bool? for instance the following code won't work because
> wxCheckBox.SetValue() expects a bool, not a number:
>
> dummy,val = cfg:Read("Foo",1)
> myCheckBox:SetValue(val)
This is again (for better or for worse) back to trying to make things
consistent, this time with Lua itself. Try this code out in Lua, you
might be unpleasantly surprised.
if 0 then print("Since when is 0 == true?") end
The answer is, 0 == true in Lua and there have been a number of
discussions on the Lua mailing list and I don't think they'll change
it.
myCheckBox:SetValue(select(cfg:Read("Foo",1), 2) ~= 0)
Hope this helps and my reasons above make sense and yes, I do
appreciate your concerns.
John Labenski
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
wxlua-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wxlua-users