Solved

Integers and Enumerated Types

Posted on 1997-04-19
3
151 Views
Last Modified: 2010-05-18

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?

0
Comment
Question by:coppola
3 Comments
 
LVL 2

Accepted Solution

by:
alona041797 earned 50 total points
ID: 1335536
Your code is correct, except it is TMonths and not TMonth:

This:
  WhichMonth := TMonths(Form1.Tag);
should work.

If this is not the problem please type the error you get.
DO NOT REJECT THIS ANSWER!
0
 
LVL 3

Expert Comment

by:mheacock
ID: 1335537
Ah, reject it...just out of principle...she/he used CAPS, which is akin to her/he shouting at you!!  Heh heh.

But I might want to answer this..... *sigh*
0
 

Author Comment

by:coppola
ID: 1335538
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(TModules(TMenuItem(Sender).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.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now