Subj : Re: enumerated variables - how to coerce them to anything else than an Int ? To : borland.public.cpp.borlandcpp From : R.Wieser Date : Tue Oct 11 2005 01:24 am John F(dot) schreef in berichtnieuws 434ac7a7$1@newsgroups.borland.com... Hello John, [snip] > Try including a value larger than maximum int. I just tried it. Guess what : the compiler complained about the value not fitting in an Int. :-\ > OK so far. what are the values for def, y, n ? My intention (with the declaration I showed) was to give them the values 0, 1 and 2 (although I did not yet check if that really happens). > and why weren't they designed to be enums then? :-) They probably where .... But the structure I've currently got is only a recreation, not the origional. I made it by looking how changes settings in a program changed the stored data. Yep, a bit of reverse engeneering :-) [snip] > Are you allowed to change the structure??? How comes that? It's an old program for which I want to be able to create different setups, without manually having to select them in the program itself. A template-generator if you will. > Do you still need to store arbitrary longs into these member-variables? Alas, yes. I can't change anything about the program itself. The only thing I *could* do is to split a number of fields of the type Long into two fields of the type Int. That would most-of-the-time work, as most enumerations are done with small positive numbers. But I would like to find a method that is of more generic use (for Ints as wel as other types). > Could you give a short snippet of the code you need to be done? Well, currently it's just a structure with some fields. And some of those fields only may have (the numerical equivalent) of certain settings (like "default", "yes" or "no"). struct { UseLpt=default; -- default, com1, com2, lpt1, lpt2, lpt3 ComHandshake=none; -- none, hardware, xonxoff Baudrate=9600; -- 50, 75, 110, 150, 1200, 2400, 9600 -- etc. } Settings; That's about what it should look like (I used "--" instead of two slashes, as IE mucks those up) Regards, Rudy Wieser .