Murga-Projects Forums
Enumerations - Printable Version

+- Murga-Projects Forums (http://www.murga-projects.com/forum)
+-- Forum: Project Forums (/forumdisplay.php?fid=1)
+--- Forum: MurgaLua - General (/forumdisplay.php?fid=2)
+--- Thread: Enumerations (/showthread.php?tid=42)


Enumerations - mikshaw - 06-07-2007 03:56 AM

Something that I keep forgetting to put in use....

The FLTK constants listed in enumerations.html file (and those that aren't listed) can be called with a number rather than a name.
This makes it more difficult to read a script, but makes it slightly smaller in size, maybe slightly less ram use but i couldn't say for sure.

For example, "widget:box(fltk.FL_UP_BOX)" could be written "widget:box(2)"

I believe this can be done for all FLTK constants.

I suppose this is why they're called "enumerations"?


RE: Enumerations - iGame3D - 06-07-2007 06:12 AM

I was looking at a similiar procedure today for lua in Bang3D, and we do the same thing in iGame3D's core.lua.

Although I've never been confident enough myself to use numbers instead of names, i'd need to program a program just to help me use the numbers.

Perhaps use the enumerations in a new version of the cxx convertor?

cxxToEnumeratedLua?


RE: Enumerations - widged - 06-07-2007 07:11 AM

iGame3D Wrote:
Perhaps use the enumerations in a new version of the cxx convertor?


In fact, it is useful to check out the list of numbers as not all flags seem to be understood in murgalua. For instance, FL_WHEN_CHANGED wasn't recognized and I had to use 1 as argument instead

Full list of constants


RE: Enumerations - mikshaw - 06-07-2007 08:16 AM

Quote:
FL_WHEN_CHANGED wasn't recognized

This might be a stupid question, but did you try "fltk.FL_WHEN_CHANGED"?
I think murgaLua needs to be told explicitly to access FLTK constants and functions using "fltk.*"

Instead of telling me I'm an idiot, please just ignore this if I'm being obvious =o)


RE: Enumerations - widged - 06-07-2007 08:23 AM

mikshaw Wrote:

Quote:
FL_WHEN_CHANGED wasn't recognized

This might be a stupid question, but did you try "fltk.FL_WHEN_CHANGED"?


That's an excellent point...sorry for the confusion I introduced when using shorthand rather than full syntax. Rapid way to check out:

Code:
frame2:box(fltk.FL_SHADOW_BOX)  

--> doesn't show any box (defaults to NO_BOX?)

Code:
frame2:box(23)

--> shows the expected box (FL_SHADOW_BOX {23;})

In other words, when the code doesn't do what you expect, it's worth to try and use the numeric value for the constant instead of the string variant.


RE: Enumerations - mikshaw - 06-07-2007 09:07 AM

I just tried widget:box(23) and got the results I'd expect from widget:box(3), which looks like it must be FL_DOWN_BOX. One of the first tests I did with murgaLua was displaying all of the available FLTK boxes, and FL_SHADOW_BOX was one that didn't work, although it wasn't listed in unimplementedFltk.txt

I wonder if there are many features that work differently depending on your platform. FLTK and Lua are apparently supposed to work the same cross-platform, but I guess that can change when you build a whole new framework from them.
My puter: Slackware Linux x86, murgaLua 0.4.1