Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Delphi Types.

Posted on 1999-06-28
10
Medium Priority
?
315 Views
Last Modified: 2010-04-06
I am new to delphi, however I am familiar to C++. I am trying to learn Delphi, but I can't find an equvalant for enum typedefs. Could someone please tell me what the equivalant is.
0
Comment
Question by:lunatik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 15

Expert Comment

by:simonet
ID: 1385104
C to Pascal

 C type              Pascal type
-------------------------------
 unsigned char       byte
 char                char
 char name[arSize]   array [0..arSize - 1] of Char
 int                 integer
 unsigned int        word
 long                longint
 unsigned long       longint
 float               single
 double              double
 char far *          PChar
 char *              PChar if large memory model, Word in small and medium
 SomeType far *      Var aName: SomeType
                     or PSomeType (type PSomeType = ^SomeType) if you

                     need the option to pass Nil as a value
 struct              record
 union               record with variants
 enum                enumerated type with compiler switch $Z+ set (default is $Z-!)

An Enum typedef is something like

Type
  TMyEnum = (meEnum1, meEnum2, me Enum3);

Yours,

Alex
Athena's Place: http://www.bhnet.com.br/~simonet



0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 300 total points
ID: 1385105
An enum type def looks like this:

type
  TMyEnum = (idOne, idTwo);

var
  TheEnumVar : TMyEnum;
...

TheEnumVar := idTwo;

Note you can't do this in Delphi

  TMyEnum = (idOne = 5, idTwo = 10);

idOne will has an ordinal value of 0 and idTwo has an ordinal value of 1.

Cheers,

Raymond.

0
 
LVL 2

Expert Comment

by:kjteng
ID: 1385106
Read the help on "enumerated type"
example:

type
  Suit = (Club, Diamond, Heart, Spade);
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 15

Expert Comment

by:simonet
ID: 1385107
That list didn't look too good in Arial. Sorry about that.

Alex
0
 

Author Comment

by:lunatik
ID: 1385108
What if the enum has something like

type
 tdef = ( a = b, dog, cat);

the compiler gives an error for the a = b. What do you do in that instance.
0
 
LVL 15

Expert Comment

by:simonet
ID: 1385109
Raymond, that is basically what I said.

Alex
0
 
LVL 15

Expert Comment

by:simonet
ID: 1385110
Humpf.
0
 

Author Comment

by:lunatik
ID: 1385111
Sorry. C and C++ is all I know. That is why I am trying to learn Delphi. It is just confusing trying to do the conversions. It does help thanks.

Jason
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1385112
Simonet: Such timing! We both posted at 10:29. The funny thing is that when I posted my answer, your comment didn't come up, which is really strange as it appears your comment is before mine.

Perhaps EE needs to time posts to the second :-)

Cheers,

Raymond.

0
 

Author Comment

by:lunatik
ID: 1385113
hehehe. agreed
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

670 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