coppola
asked on
Integers and Enumerated Types
Does anyone know how to accomplish this?
type
TMonths = (January, February, March, etc.);
var
WhichMonth : TMonths;
...
Form1.Tag := ord(WhichMonth);
{More Code}
WhichMonth := TMonth(Form1.Tag) <<== This is the problem
...
How do you get from an integer type to an enumerated type?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
My problem was not a typo. I'm using TMonths as an example. My code is more involved and I thought that this would be easier to follow using months.
The problem persists. The error I get is at compile time:
Incompatible Types integer and TModules
The actual code generating the error is:
previousModule := currentModule;
currentModule := constructModuleFromID(TMod ules(TMenu Item(Sende r).Tag));
if currentModule <> nil then begin
currentModule.Start;
previousModule.Free;
end;
A little more research has led me to believe that this is an order of evaluation problem. If I declare a TModules variable and perform the type conversion before the function call, it works.
The problem persists. The error I get is at compile time:
Incompatible Types integer and TModules
The actual code generating the error is:
previousModule := currentModule;
currentModule := constructModuleFromID(TMod
if currentModule <> nil then begin
currentModule.Start;
previousModule.Free;
end;
A little more research has led me to believe that this is an order of evaluation problem. If I declare a TModules variable and perform the type conversion before the function call, it works.
But I might want to answer this..... *sigh*