Solved

Property with a pick list

Posted on 2009-07-03
1
349 Views
Last Modified: 2013-11-23
I want to create a delphi object with a property which can be
one of the follow values:

(PENDING,DOWN,UP,SLEEPING....)

So that in my code i can do things like that:

Actor.Status := PENDING;
Node.Status := UP;

Should I define my const value and use them in a property?

Someone can show me how to do it, plz?
 
0
Comment
Question by:jaja2005
1 Comment
 
LVL 3

Accepted Solution

by:
btframework earned 500 total points
ID: 24771201
type
  TMyStatus = (PENDING, DOWN, UP, SLEEP);

  TActor = class()
  private
    FStatus: TMyStatus;

  public
    property Status: TMyStatus read FStatus write SetStatus;
  endl

Something like that.

If TActore is not your class then you can define enumeration like:

type
  TMysStatus = (PENDING = 100, DOWN = 200, UP = 5, SLEEP = 1);

where 100, 200, 5 and 1 are the actual values defined for the class.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

810 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