Murga-Projects Forums

Full Version: Enumerations
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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"?
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?

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

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)

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.

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
Reference URL's